from machine import Pin
from utime import sleep_ms
BTN = Pin(17, Pin.IN, Pin.PULL_UP) # Active-low button
while True:
pressed = (BTN.value() == 0)
if pressed:
print("ON")
else:
print("OFF")
sleep_ms(20)