Light sensor

LDR voltage divider

Adjust light level and threshold to see divider voltage, ADC reading, and automatic LED state change.

Voltage divider Vout = Vcc x Rfixed / (RLDR + Rfixed)

Vout = 3.3 V x 10k / (36k + 10k) = 0.72 V

Threshold logic ADC < threshold = dark

Bright: LED OFF

3.3V GND
LDR
10k
Vout 0.72V
ESP32 GPIO34 ADC 893
LED OFF
Threshold 1800
Light level65%
LDR resistance36k ohm
Divider voltage0.72 V
ADC / LED893 / OFF