/* Svetofor Turns on an LED on for one second, then off for one second, repeatedly. This example code is in the public domain. */ void setup() { // initialize the digital pin as an output. // Pin 13 has an LED connected on most Arduino boards: pinMode(13, OUTPUT); // mode indicator (normal/blink yellow) pinMode(12, OUTPUT); pinMode(8, OUTPUT); pinMode(7, OUTPUT); pinMode(4, OUTPUT); pinMode(2, OUTPUT); pinMode (11, INPUT); // LOW = normal / HIGH = blink yellow #define RED 12 #define YELLOW 8 #define GREEN 7 #define RED2 4 #define GREEN2 2 } void loop() { if (digitalRead(11) == LOW) { digitalWrite(13, LOW); digitalWrite(RED, LOW); digitalWrite(GREEN, LOW); digitalWrite(RED2, LOW); digitalWrite(GREEN2, LOW); digitalWrite(YELLOW, LOW); delay(500); digitalWrite(YELLOW, HIGH); delay(500); } else { digitalWrite(13, HIGH); digitalWrite(YELLOW, LOW); // RED digitalWrite(RED, HIGH); // set the LED on digitalWrite(RED2, LOW); // set the LED off digitalWrite(GREEN2, HIGH); // set the LED on delay(22000); // wait for a second digitalWrite(GREEN2, LOW); // set the LED off delay(500); // wait for a second digitalWrite(GREEN2, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(GREEN2, LOW); // set the LED off delay(500); // wait for a second digitalWrite(GREEN2, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(GREEN2, LOW); // set the LED off delay(500); // wait for a second digitalWrite(GREEN2, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(GREEN2, LOW); // set the LED off // YELLOW digitalWrite(YELLOW, HIGH); // set the LED on delay(5000); // wait for a second digitalWrite(RED, LOW); // set the LED off digitalWrite(RED2, HIGH); // set the LED on digitalWrite(YELLOW, LOW); // set the LED off // GREEN BLINK digitalWrite(GREEN, HIGH); // set the LED on delay(22000); // wait for a second digitalWrite(GREEN, LOW); // set the LED off delay(500); // wait for a second digitalWrite(GREEN, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(GREEN, LOW); // set the LED off delay(500); // wait for a second digitalWrite(GREEN, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(GREEN, LOW); // set the LED off delay(500); // wait for a second digitalWrite(GREEN, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(GREEN, LOW); // set the LED off // YELLOW digitalWrite(YELLOW, HIGH); // set the LED on delay(5000); // wait for a second digitalWrite(YELLOW, LOW); // set the LED off } }