from machine import Pin
import time
# PIR sensor
pir = Pin(14, Pin.IN)
# LED (represents room light)
led = Pin(2, Pin.OUT)
# Optional buzzer
buzzer = Pin(4, Pin.OUT)
while True:
motion = pir.value()
if motion == 1:
print("💡 Motion Detected: LED Blinking")
# Blink LED continuously while motion is detected
led.on()
buzzer.on() # optional short beep
time.sleep(0.5)
led.off()
buzzer.off()
time.sleep(0.5)
else:
print("💤 No motion detected: LED OFF")
led.off()
buzzer.off()
time.sleep(0.5)