from machine import Pin, ADC
from time import sleep
photo = ADC(Pin(27))
led = Pin(1, Pin.OUT)
lux_threshold = 1000
adc_to_lux_factor = 0.1
while True:
current_photo_value = photo.read_u16()
estimated_lux = current_photo_value * adc_to_lux_factor
print("Estimated Lux:", estimated_lux)
if estimated_lux < lux_threshold:
led.value(1)
print("Security breach detected - low light.")
else:
led.value(0)
print("Light level is sufficient.")
sleep(1)