from machine import Pin , ADC
from time import sleep_ms

ldr = ADC(Pin(35))
ldr.atten(ADC.ATTN_11DB)
led = Pin(2,Pin.OUT)

while True:
    ldr_value=ldr.read()
    print("ldr value = ",ldr_value)
    sleep_ms(500)

    if ldr_value < 2400:
        led.off()
    else:
        led.on()
    sleep_ms(100)
Loading
esp32-devkit-c-v4