Toll-Free Customer Support 24/7

Digi dim Atmel code

#include<reg52.h>                                                             //Header file
#define DIMMER P2                                                         // dimmer ckt connected   P2
sbit UP =P1^0;                                                           //increment switch cnt tpP1.0
sbit DOWN =P1^1;                                                            //decrement switch cnt tpP1.1
void main()
{
DIMMER=0XFF;                                                              // lamp off
while(1)                                                                            //infinite loop
{
if(UP==0)                                                                         //switch pressed
{
if(DIMMER<0Xff)                             
DIMMER++;  
                                                                // increment level      
while(UP==0);                                                                 // wait till switched pressed

if(DOWN==0)                                                                  //switch pressed
{
if(DIMMER>0Xf0)
DIMMER--;                                                                      // decrement level
while(DOWN==0);                                                          // wait till switched pressed
//)
}
}
}
}

Back to top