Add pin change interrupt
This commit is contained in:
parent
4b49cfc8b5
commit
164d686df3
|
@ -0,0 +1,17 @@
|
||||||
|
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
|
Loading…
Reference in New Issue