from machine import Pin
from utime import sleep

led = Pin(10, Pin.OUT)
sw = Pin(21, Pin.IN)

def sw_handler(pin):
  if sw() == 0:
    led.on()
    sleep(0.2)
    print("ON")
  else:
    led.off()
    sleep(0.2)
    print("OFF")

sw.irq(handler = sw_handler)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT