Toll-Free Customer Support 24/7

Digital Dimmer Module

/*
* Project name:
Digital Dimmer Module
* Copyright
(c) Researchdesignlab.com
* Test configuration:
MCU: PIC16F877A
Dev.Board: PIC
Oscillator: 20.0 MHz
Software: mikroC PRO for PIC v 4.6

*/


char DIMMER=0 ;//at PORTB;
sbit UP at RC0_bit;
sbit DOWN at RC1_bit;
void main() {
TRISB=0x00;
TRISC=0xFF;
DeLAY_MS(1000);
PORTB=0x0F;
DIMMER=0x0F;
DeLAY_MS(1000);
while(1)
{
if(UP==0) //switch pressed
{
if(PORTB<0X0F)
DIMMER++;
PORTB=DIMMER;
Delay_ms(200); // increment level

}
if(DOWN==0) //switch pressed
{
if(PORTB>0X00)
DIMMER--;
PORTB=DIMMER; // decrement level

}


}
}

Back to top