from machine import Pin
from time import sleep
led_pins = [2, 3, 4, 5]
leds = [Pin(pin, Pin.OUT) for pin in led_pins]
def turn_on():
for led in leds:
led.value(1)
print("All lights are ON.")
def turn_off():
for led in leds:
led.value(0)
print("All lights are OFF.")
def blink_in_sequence():
print("Blinking LEDs in sequence...")
for i in range(5):
for led in leds:
led.value(1)
sleep(0.5)
led.value(0)
sleep(0.5)
def main():
print("How to turn on and off the light")
print("Commands:")
print("1 - Turn ON all lights")
print("2 - The lights are currently blinking")
print("3 - All four lights are off")
while True:
command = input("Enter command: ").strip()
if command == "1":
turn_on()
elif command == "2":
blink_in_sequence()
elif command == "3":
turn_off()
elif command.lower() == "q":
print("Exiting program. Goodbye!")
break
else:
print("Invalid command. Please enter 1, 2, 3, or q.")
if __name__ == "__main__":
main()