// Define the pin connections for the LEDs
const int redLedPin = 2; // Red LED connected to digital pin 2
const int yellowLedPin = 3; // Yellow LED connected to digital pin 3
const int greenLedPin = 4; // Green LED connected to digital pin 4
void setup() {
// Set the pin modes for the LEDs
pinMode(redLedPin, OUTPUT);
pinMode(yellowLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
}
void loop() {
// Turn on the Green LED for 5 seconds (vehicle go)
digitalWrite(greenLedPin, HIGH); // Green LED ON
digitalWrite(yellowLedPin, LOW); // Yellow LED OFF
digitalWrite(redLedPin, LOW); // Red LED OFF
delay(5000); // Wait for 5 seconds
// Turn on the Yellow LED for 2 seconds (warning)
digitalWrite(greenLedPin, LOW); // Green LED OFF
digitalWrite(yellowLedPin, HIGH); // Yellow LED ON
digitalWrite(redLedPin, LOW); // Red LED OFF
delay(2000); // Wait for 2 seconds
// Turn on the Red LED for 5 seconds (vehicle stop)
digitalWrite(greenLedPin, LOW); // Green LED OFF
digitalWrite(yellowLedPin, LOW); // Yellow LED OFF
digitalWrite(redLedPin, HIGH); // Red LED ON
delay(5000); // Wait for 5 seconds
}