Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Begining of Auto generated code by Atmel studio */
- #include <Arduino.h>
- /*End of auto generated code by Atmel studio */
- //Beginning of Auto generated function prototypes by Atmel Studio
- //End of Auto generated function prototypes by Atmel Studio
- // Trafficlights code by Heikki Peltomäki
- // 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.
- // 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.
- int redLight = 10;
- int yellowLight = 9;
- int greenLight = 8;
- void setup() {
- pinMode(redLight, OUTPUT);
- pinMode(yellowLight, OUTPUT);
- pinMode(greenLight, OUTPUT);
- }
- void loop() {
- // green on, yellow and red off
- digitalWrite(greenLight, HIGH);
- digitalWrite(yellowLight, LOW);
- digitalWrite(redLight, LOW);
- delay(5000);
- // turn off green, then turn yellow on for 3 seconds
- digitalWrite(greenLight, LOW)
- digitalWrite(yellowLight, HIGH);
- delay(3000);
- // yellow off and red on for 5 seconds
- digitalWrite(yellowLight, LOW);
- digitalWrite(redLight, HIGH);
- delay(5000);
- // turn yellow on with red or 2,5 seconds
- digitalWrite(yellow, HIGH);
- delay(2500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement