#https://microcontrollerslab.com/pir-motion-sensor-raspberry-pi-pico/
from machine import Pin
import utime
from machine import PWM
buzzer = PWM(Pin(15))
# tone of buzzer
buzzer.freq(500)
# Pin(Pin_number,
# pin_mode (IN, OUT, OPEN_DRAIN),
# Internal resistor pull value(PULL_UP OR PULL_DOWN),
# value (1 0r 0))
#
LED = Pin(14,Pin.OUT)
PIR = Pin(13,Pin.IN, Pin.PULL_UP)
LED.low()
utime.sleep(2)
while True:
motion = PIR.value()
print(motion)
if motion == 1:
print("motion detected")
LED.high()
utime.sleep(3)
# volume of buzzer
buzzer.duty_u16(1000)
else:
print("no motion detected")
LED.low()
buzzer.duty_u16(0)
utime.sleep(3)