Energy Saver System:
Code:
#pragma config OSC = HS#pragma config OSCS = OFF
#pragma config PWRT = OFF
#pragma config BOR = ON
#pragma config BORV = 45
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config DEBUG = OFF
#pragma config STVR = OFF
#define s1 PORTB.F0
#define s2 PORTB.F1
#define s3 PORTB.F2
#define o1 PORTC.F0
#define o2 PORTC.F1
#define o3 PORTC.F2
void main()
{
TRISC= 0x00;
TRISB= 0xff;
while(1)
{
o3=0;
o1=0;
o2=0;
while(s1==1)
{
o1=1;
o2=0;
o3=0;
delay_ms(100);
}
while(s2==1)
{
o2=1;
o1=0;
o3=0;
delay_ms(100);
}
while(s3==1)
{
o3=1;
o1=0;
o2=0;
delay_ms(100);
}
}
}
0 comments:
Post a Comment
if you have any doubt please let me know