from machine import Pin
from time import sleep
# Define pin numbers
RED_PIN = 15 # Adjust to the correct GPIO number in Wokwi
YELLOW_PIN = 2 # Adjust to the correct GPIO number in Wokwi
GREEN_PIN = 4 # Adjust to the correct GPIO number in Wokwi
# Set up the pins as outputs
red_led = Pin(RED_PIN, Pin.OUT)
yellow_led = Pin(YELLOW_PIN, Pin.OUT)
green_led = Pin(GREEN_PIN, Pin.OUT)
def loop():
# Turn on the green LED
green_led.value(1)
sleep(3)
# Turn off the green LED and turn on the yellow LED
green_led.value(0)
yellow_led.value(1)
sleep(0.5)
# Turn off the yellow LED and turn on the red LED
yellow_led.value(0)
red_led.value(1)
sleep(2)
# Turn on the yellow LED while the red LED is still on
yellow_led.value(1)
sleep(0.5)
# Turn off both yellow and red LEDs
yellow_led.value(0)
red_led.value(0)
# Run the loop function indefinitely
while True:
loop()