from machine import Pin
from time import sleep
pir_pin = Pin(14, Pin.IN)
led_pin = Pin(13, Pin.OUT)
buzzer_pin = Pin(12, Pin.OUT)
while True:
    if pir_pin.value() == 1:
        print("Motion Detected")
        buzzer_pin.value(1)
        led_pin.value(1)
        sleep(3)  # Keep buzzer and LED on for 3 seconds
        buzzer_pin.value(0) 
        led_pin.value(0)
        print("Motion Stopped")
    
    sleep(0.1)  # Add a slight delay to reduce CPU usage