EL-78IntermediatePremiumOp-amp circuits
Precision Dark Switch
When the room gets dark, the yellow LED lights by itself, and when it gets bright again it goes out. The LDR turns light into a voltage, and the LM358 compares this voltage with a threshold you set with the pot. A 220 kΩ resistor fed back from the output adds hysteresis: the LED lights at about 9.3 lux and goes out at 10.5 lux, so it does not flicker even when the light changes slowly. You learn about the comparator, hysteresis and the lux calculation.
0.0(0)

It is built with a 9 V battery, one LM358, one LDR (GL5528 type), a 10 kΩ pot, four resistors, one capacitor and a yellow LED. The divider made of 10 kΩ and the LDR goes to the + input of the LM358 (pin 3), and the wiper of the pot goes to the − input (pin 2). In the dark the resistance of the LDR rises, the + input passes the threshold and the output lights the LED. The threshold can be set with the pot from about 4 lux to a few hundred lux. What you learn: comparator, hysteresis, calculating lux from the LDR.
Premium Content
This circuit's build steps, how-it-works guide and FAQ are open to Premium members.
- Build Steps
- How It Works
- Frequently Asked Questions
