import machine
import time
# Define the GPIO pins for the LEDs and buttons
led_pins = [0, 1, 2, 3]
button_pins = [17, 18, 19, 20]
# Setup the GPIO pins
leds = [machine.Pin(pin, machine.Pin.OUT) for pin in led_pins]
buttons = [machine.Pin(pin, machine.Pin.IN, machine.Pin.PULL_UP) for pin in button_pins]
# Loop forever
while True:
# Check if any button is pressed
for i, button in enumerate(buttons):
if not button.value():
# Button is pressed, turn on/off the corresponding LED
led = leds[i]
led.value(not led.value())
time.sleep(0.1) # debounce the button