micropython-examples/interrupt/external.py

18 lines
331 B
Python
Raw Normal View History

2021-06-17 07:52:02 +00:00
from machine import Pin
from time import sleep
led = Pin(2, Pin.OUT)
def callback(p):
print('pin change', p, p.value())
sleep(0.1)
button1 = Pin(13, Pin.IN)
button1.irq(trigger=Pin.IRQ_FALLING, handler=callback)
button2 = Pin(14, Pin.IN)
button2.irq(trigger=Pin.IRQ_FALLING, handler=callback)
while True:
pass