import time
from machine import Pin
red_led = Pin(1, Pin.OUT)
yellow_led = Pin(2, Pin.OUT)
green_led = Pin(3, Pin.OUT)
blue_led = Pin(4, Pin.OUT)
def turn_off_all():
red_led.off()
yellow_led.off()
green_led.off()
blue_led.off()
def display_menu():
print("1 - Turn on Red LED")
print("2 - Turn on Yellow LED")
print("3 - Turn on Green LED")
print("4 - Turn on Blue LED")
print("5 - Blink LEDs in sequence")
print("6 - Turn off all LEDs")
print("0 - Exit")
while True:
display_menu()
choice = input("Enter your choice: ")
if choice == "1":
turn_off_all()
red_led.on()
print("Red LED is ON.")
elif choice == "2":
turn_off_all()
yellow_led.on()
print("Yellow LED is ON.")
elif choice == "3":
turn_off_all()
green_led.on()
print("Green LED is ON.")
elif choice == "4":
turn_off_all()
blue_led.on()
print("Blue LED is ON.")
elif choice == "5":
print("Blinking LEDs in sequence...")
for _ in range(5):
red_led.on()
time.sleep(0.5)
red_led.off()
yellow_led.on()
time.sleep(0.5)
yellow_led.off()
green_led.on()
time.sleep(0.5)
green_led.off()
blue_led.on()
time.sleep(0.5)
blue_led.off()