two traffic lights together with different delays
#define RED_PIN 4 #define YELLOW_PIN 3 #define GREEN_PIN 2 #define RED2_PIN 13 #define YELLOW2_PIN 11 #define GREEN2_PIN 9 void setup(){ pinMode(RED_PIN, OUTPUT); pinMode(YELLOW_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); pinMode(RED2_PIN, OUTPUT); pinMode(YELLOW2_PIN, OUTPUT); pinMode(GREEN2_PIN, OUTPUT); } void loop(){ digitalWrite(YELLOW_PIN, LOW); digitalWrite(RED_PIN, LOW); digitalWrite(YELLOW2_PIN, LOW); digitalWrite(RED2_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); delay(500); digitalWrite(GREEN_PIN, LOW); digitalWrite(GREEN2_PIN, HIGH); delay(1000); digitalWrite(GREEN_PIN, LOW); digitalWrite(GREEN2_PIN, LOW); digitalWrite(RED_PIN, LOW); digitalWrite(RED2_PIN, LOW); digitalWrite(YELLOW_PIN, HIGH); delay(500); digitalWrite(YELLOW_PIN, LOW); digitalWrite(YELLOW2_PIN, HIGH); delay(1000); digitalWrite(GREEN_PIN, LOW); digitalWrite(YELLOW_PIN, LOW); digitalWrite(GREEN2_PIN, LOW); digitalWrite(YELLOW2_PIN, LOW); digitalWrite(RED_PIN, HIGH); delay(500); digitalWrite(RED_PIN, LOW); digitalWrite(RED2_PIN, HIGH); delay(1000); }
Leave a Comment