from machine import Pin
import time
pir_sensor_pin = Pin(12, Pin.IN)
led_pin = Pin(14, Pin.OUT)
buzzer_pin = Pin(27, Pin.OUT)
def check_motion():
return pir_sensor_pin.value()
while True:
if check_motion():
led_pin.on()
buzzer_pin.on()
print("Motion detected!")
else:
led_pin.off()
buzzer_pin.off()
print("No motion")
time.sleep(1)