from machine import Pin
from utime import sleep
print("LED control with button")
led = Pin(15, Pin.OUT)
button = Pin(27, Pin.IN, Pin.PULL_UP)
pressed = False
while True:
current_pressed = button.value() == 0
if not pressed and current_pressed:
led.value(not led.value())
pressed = current_pressed
sleep(0.005)