Add pin change interrupt

This commit is contained in:
Jimmy 2021-06-17 19:52:02 +12:00
parent 4b49cfc8b5
commit 164d686df3
1 changed files with 17 additions and 0 deletions

17
interrupt/external.py Normal file
View File

@ -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