from machine import Pin
from utime import sleep
pin_led = Pin(2, Pin.OUT)
pin_pir = Pin(14, Pin.IN)
# SUBINTERUPT FOR INTERUPT
def interupt_pir(pin):
print('MOTION DETECTED! Interupted by',pin)
pin_led.on()
sleep(10)
pin_led.off()
print('MOTION STOPPED!')
# MAIN ROUTINE
pin_pir.irq(trigger=Pin.IRQ_RISING, handler=interupt_pir)
while True:
pin_led.off()
# Pin.IRQ_RISING = Posedge
# Pin.IRQ_FALLING = Negedge
# 3 = Both Edges