import time
from machine import Pin,PWM
sens1 = Pin(6,Pin.IN,Pin.PULL_DOWN)
sens2 = Pin(27,Pin.IN,Pin.PULL_DOWN)
buzz = PWM(Pin(13,Pin.OUT))
buzz.freq(800)
led = Pin(0,Pin.OUT)
def alarm():
led.on()
buzz.duty_u16(32767)
time.sleep(0.1)
buzz.duty_u16(0)
time.sleep(0.1)
buzz.duty_u16(32767)
time.sleep(0.1)
buzz.duty_u16(0)
led.off()
time.sleep(2)
while True:
if sens1.value() == 1:
print("Motion Detected on Top")
alarm()
if sens2.value() == 1:
print("Motion Detected on Bottom")
alarm()