Advertisement
Guest User

Bicycle Indicators

a guest
Apr 26th, 2014
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1.  
  2. int switchstateL = 0;
  3. int switchstateR = 0;
  4.  
  5. int LeftLed = 4;
  6. int RightLed = 6;
  7.  
  8. int LeftButton = 3;
  9. int RightButton = 5;
  10.  
  11. int FlashRate = 150;
  12.  
  13. void setup(){
  14.   // declare the LED pins as outputs
  15.   pinMode(LeftLed,OUTPUT);
  16.   pinMode(RightLed,OUTPUT);
  17.  
  18.   // declare the switch pin as an input  
  19.   pinMode(LeftButton,INPUT);
  20.   pinMode(RightButton,INPUT);
  21. }
  22.  
  23. void loop(){
  24.   switchstateL = digitalRead(3);
  25.   switchstateR = digitalRead(5);
  26.  
  27.   if (switchstateL == LOW) {
  28.     digitalWrite(LeftLed, LOW);  // turn the red LED on pin 4 off
  29.   }
  30.   else {
  31.     digitalWrite(LeftLed, LOW);  // turn the red LED on pin 4 off
  32.     delay(FlashRate);
  33.     digitalWrite(LeftLed, HIGH); // turn the red LED on pin 4 on
  34.     delay(FlashRate);
  35.   }
  36.  
  37.     if (switchstateR == LOW) {
  38.     digitalWrite(RightLed, LOW);  // turn the red LED on pin 4 off
  39.   }
  40.   else {
  41.     digitalWrite(RightLed, LOW);  // turn the red LED on pin 4 off
  42.     delay(FlashRate);
  43.     digitalWrite(RightLed, HIGH); // turn the red LED on pin 4 on
  44.     delay(FlashRate);
  45.   }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement