from machine import Pin, ADC
import time
ldr_pin = ADC(Pin(26))
led = Pin(15, Pin.OUT)
light_threshold = 30000
while True:
light_value = ldr_pin.read_u16()
print(f"Light Value: {light_value}")
if light_value < light_threshold:
led.value(1) # LED on
print("It's dark, turning the LED ON")
else:
led.value(0) # LED off
print("It's bright, turning the LED OFF")
time.sleep(0.5)