from machine import Pin,PWM
from time import sleep

motion = False

def handle_interrupt(pin):  
    if pin == pir1:
        print("Motion detected at location 1")
        led1.value(1)
    elif pin == pir2:
        print("Motion detected at location 2")
        led2.value(1)
    buzzer.duty_u16(1000)
    sleep(1)  
    led1.value(0)
    led2.value(0)     
    buzzer.duty_u16(0)  
  
led1 = Pin(3, Pin.OUT , Pin.PULL_DOWN)
pir1 = Pin(28, Pin.IN , Pin.PULL_DOWN)
pir1.irq(trigger = Pin.IRQ_RISING, handler = handle_interrupt)

led2 = Pin(3, Pin.OUT , Pin.PULL_DOWN)
pir2 = Pin(16, Pin.IN , Pin.PULL_DOWN)
pir2.irq(trigger = Pin.IRQ_RISING, handler = handle_interrupt)

buzzer = PWM(Pin(3))
buzzer.freq(500)
$abcdeabcde151015202530fghijfghij
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT