from machine import Pin
import time
LEDs = [Pin(19, Pin.OUT), Pin(18, Pin.OUT), Pin(2, Pin.OUT), Pin(15, Pin.OUT)]
KEYs = [Pin(34, Pin.IN, Pin.PULL_UP), Pin(35, Pin.IN, Pin.PULL_UP), Pin(32, Pin.IN, Pin.PULL_UP), Pin(33, Pin.IN, Pin.PULL_UP)]
def toggle_led(index):
LEDs[index].value(not LEDs[index].value())
def handle_button_press(pin):
time.sleep_ms(10)
if pin.value() == 0:
toggle_led(KEYs.index(pin))
for key in KEYs:
key.irq(handler=handle_button_press, trigger=Pin.IRQ_FALLING)