Code: Select all
from machine import Pin
import utime
radar_interrupt = False
def handle_interrupt(xyz): # needs something
global radar_interrupt
radar_interrupt = True
pir = Pin(18, Pin.IN, Pin.PULL_UP)
pir.irq(trigger=Pin.IRQ_FALLING, handler=handle_interrupt)
# main loop
while True:
radar_interrupt = False # 1st one works
while True:
if (radar_interrupt == True):
break
# radar_interrupt = False # 2nd doesn't work
print ('got got an interrupt')
utime.sleep(1)
However, if I comment out the 1st radar_interrupt = False and put in the 2nd one I get two interrupts. It seems even though I have broken out of the test loop for interrupts that radar_interrupt has not been made False and that I have to wait at least 0.1 seconds before it is reset..
Can someone identify my knowledge gap?