# reference https://wokwi.com/projects/392231924047630337
from machine import Pin
import time
PIR_pin = 22 # Select the pin for the motion sensor
Buzzer_pin = 15 # Select the pin for the buzzer
LED_pin = 6
sensor = Pin(PIR_pin,Pin.IN)
buzzer = Pin(Buzzer_pin, Pin.OUT)
led = Pin(LED_pin, Pin.OUT)
while True:
if(sensor.value()==1):
led.value(1)
buzzer.value(1)
print("Motion Detected")
else:
led.value(0)
buzzer.value(0)
print("Motion Not Detected")
time.sleep(0.5)