We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
Try this:
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; }