0from machine import Pin
from time import sleep
# Button LED control
button = Pin(4, Pin.IN, Pin.PULL_UP) # Internal pull-up
led = Pin(2, Pin.OUT) # Built-in LED or external
while True:
if not button.value(): # Button pressed
led.on()
else:
led.off()
sleep(0.05)
print("Button:", button.value())