import machine
from machine import Pin
import utime
motionpin_1 = Pin(1, Pin.IN, Pin.PULL_DOWN)
motionpin_2 = Pin(2, Pin.IN, Pin.PULL_DOWN)
buzzerpin = Pin(3, Pin.OUT)
led=Pin(0, Pin.OUT)
def motion_handler(pin):
if pin == motionpin_1:
print("motion from first motion sensor detected")
elif pin == motionpin_2:
print("motion from second motion sensor detected")
led.on()
buzzerpin.on()
utime.sleep(0.5)
buzzerpin.off()
led.off()
while True:
motionpin_1.irq(trigger=Pin.IRQ_RISING, handler=motion_handler)
motionpin_2.irq(trigger=Pin.IRQ_RISING, handler=motion_handler)
utime.sleep(0.1)