from machine import Pin, ADC
import time
pir = Pin(15, Pin.IN)
led = Pin(14, Pin.OUT)
buzzer = Pin(13, Pin.OUT)
ldr = ADC(26) # AO connected to GP26
DARK_THRESHOLD = 30000 # adjust as needed
while True:
motion = pir.value()
light = ldr.read_u16()
print("Motion:", motion, "Light:", light)
if motion == 1 and light < DARK_THRESHOLD:
led.value(1)
buzzer.value(1)
else:
led.value(0)
buzzer.value(0)
time.sleep(0.5)