// Define pins for LEDs
const int redLED = 8;
const int yellowLED = 9;
const int greenLED = 10;
// Define delays (in milliseconds)
const int redDelay = 5000; // Red light duration (5 seconds)
const int yellowDelay = 2000; // Yellow light duration (2 seconds)
const int greenDelay = 5000; // Green light duration (5 seconds)
void setup() {
// put your setup code here, to run once:
//Set LED pins as output
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//Red light on
digitalWrite(redLED, HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
delay(redDelay);
//Yellow light on
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, HIGH);
digitalWrite(greenLED, LOW);
delay(yellowDelay);
//Green light on
digitalWrite(redLED, LOW);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, HIGH);
delay(greenDelay);
}