Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Begining of Auto generated code by Atmel studio */
  2. #include <Arduino.h>
  3.  
  4. /*End of auto generated code by Atmel studio */
  5.  
  6.  
  7. //Beginning of Auto generated function prototypes by Atmel Studio
  8. //End of Auto generated function prototypes by Atmel Studio
  9.  
  10. // Trafficlights code by Heikki Peltomäki
  11. // The code will cause the three LEDs (red, yellow, green) to act as traffic lights. Green starts for 5seconds, then it turns yellow and then red. Interval is 3sec.
  12. // After staying red for 5sec, yellow will shine with red for 2,5sec and then the green will turn on for 5sec, while yellow and red shut down.
  13.  
  14.     int redLight = 10;
  15.     int yellowLight = 9;
  16.     int greenLight = 8;
  17.  
  18. void setup() {
  19.  
  20.     pinMode(redLight, OUTPUT);
  21.     pinMode(yellowLight, OUTPUT);
  22.     pinMode(greenLight, OUTPUT);
  23. }
  24.  
  25. void loop() {
  26.       // green on, yellow and red off
  27.       digitalWrite(greenLight, HIGH);
  28.       digitalWrite(yellowLight, LOW);
  29.       digitalWrite(redLight, LOW);
  30.       delay(5000);
  31.  
  32.       // turn off green, then turn yellow on for 3 seconds
  33.       digitalWrite(greenLight, LOW)
  34.       digitalWrite(yellowLight, HIGH);
  35.       delay(3000);
  36.  
  37.       // yellow off and red on for 5 seconds
  38.       digitalWrite(yellowLight, LOW);
  39.       digitalWrite(redLight, HIGH);
  40.       delay(5000);
  41.  
  42.       // turn yellow on with red or 2,5 seconds
  43.       digitalWrite(yellow, HIGH);
  44.       delay(2500);
  45.      
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement