Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int switchstateL = 0;
- int switchstateR = 0;
- int LeftLed = 4;
- int RightLed = 6;
- int LeftButton = 3;
- int RightButton = 5;
- int FlashRate = 150;
- void setup(){
- // declare the LED pins as outputs
- pinMode(LeftLed,OUTPUT);
- pinMode(RightLed,OUTPUT);
- // declare the switch pin as an input
- pinMode(LeftButton,INPUT);
- pinMode(RightButton,INPUT);
- }
- void loop(){
- switchstateL = digitalRead(3);
- switchstateR = digitalRead(5);
- if (switchstateL == LOW) {
- digitalWrite(LeftLed, LOW); // turn the red LED on pin 4 off
- }
- else {
- digitalWrite(LeftLed, LOW); // turn the red LED on pin 4 off
- delay(FlashRate);
- digitalWrite(LeftLed, HIGH); // turn the red LED on pin 4 on
- delay(FlashRate);
- }
- if (switchstateR == LOW) {
- digitalWrite(RightLed, LOW); // turn the red LED on pin 4 off
- }
- else {
- digitalWrite(RightLed, LOW); // turn the red LED on pin 4 off
- delay(FlashRate);
- digitalWrite(RightLed, HIGH); // turn the red LED on pin 4 on
- delay(FlashRate);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement