This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to work the 89C51 with a switch

hi
I am pretty much new with the 89C51 (atmel 89C51). I am trying to turn on LED with the switch. I can turn on one LED but when i try to turn on two LED it does not work. Right now both the LED turns on with the same switch. But i want to turn on the two LED with two different switch.
my program is as follows

sbit DIPswitch1=P1^4;
sbit DIPswitch2=P1^3;
sbit greenLED1=P1^5;
sbit greenLED2=P1^6;

void main(void)
{
while(1)
{
if (DIPswitch1==1)
greenLED1=0;
else
greenLED1=1;
}
{ if (DIPswitch2==1)
greenLED2=0;
else
greenLED2=1;
}

Any help will be appreciated
thanx

Parents Reply Children
No data