from machine import Pin, Timer
import time
led_pin = Pin(15, Pin.OUT)
led_pin.value(0)
button_pin = Pin(18, Pin.IN, Pin.PULL_UP)
timer = Timer(0)
def tipped(pin):
print("led:",led_pin.value())
led_pin.value(not led_pin.value())
def debounce(pin):
timer.init(mode=Timer.ONE_SHOT, period=100, callback= tipped)
button_pin.irq(handler=debounce, trigger=Pin.IRQ_FALLING)
while True:
time.sleep(1)