from machine import Pin
from utime import sleep
# Set up the LED and button
led = Pin(2, Pin.OUT)
pb = Pin(20, Pin.IN, Pin.PULL_UP)
# Main loop
while True:
if pb.value() == 0: # Button is pressed
led.on()
else: # Button is not pressed
led.off()
sleep(0.1) # Small delay to debounce the button