// Define pins for the LEDs and button
const int redPin = 9; // Red LED
const int greenPin = 10; // Green LED
const int buttonPin = 2; // Button
const int YellowPin = 8; // Yellow LED
const int BluePin = 7; // Blue Pin
// Setup function runs once at the beginning of the program
void setup() {
// Set the button pin as input with an internal pull-up resistor
pinMode(buttonPin, INPUT_PULLUP);
// Turn on the green LED pin
digitalWrite(greenPin, HIGH);
// Make sure that the red LED pin is off
digitalWrite(redPin, LOW);
}
// Loop function runs continuously after the setup function
void loop() {
// Check if the button is pressed
if (digitalRead(buttonPin) == LOW) {
// Turn on the red light and wait for 5 seconds
delay(5000);
// Turn off the green light and turn on the yellow light for 3 seconds
digitalWrite(greenPin, LOW);
digitalWrite(YellowPin, HIGH);
delay(3000);
// Turn off the yellow light and turn on the red and blue lights for 5 seconds
digitalWrite(YellowPin, LOW);
digitalWrite(redPin, HIGH);
digitalWrite(BluePin, HIGH);
delay(5000);
// Flash the blue light on and off five times with one second delay between each flash
digitalWrite(BluePin, LOW);
delay(1000);
digitalWrite(BluePin, HIGH);
delay(1000);
digitalWrite(BluePin, LOW);
delay(1000);
digitalWrite(BluePin, HIGH);
delay(1000);
digitalWrite(BluePin, LOW);
delay(1000);
digitalWrite(BluePin, HIGH);
delay(1000);
digitalWrite(BluePin, LOW);
delay(1000);
digitalWrite(BluePin, HIGH);
delay(1000);
digitalWrite(BluePin, LOW);
delay(1000); // Turn off the red and blue lights and turn on the green light
digitalWrite(redPin, LOW);
digitalWrite(BluePin, LOW);
digitalWrite(greenPin, HIGH);
}
else // If the button is not pressed, turn on the green light
digitalWrite(greenPin, HIGH);
}