BeginnerLighting
Dark-Activated Night Light
Use an LM358 as a light-level comparator so an LED turns on when the room gets dim.
Parts from the database
- LM358P × 1Dual operational amplifier
Other supplies
- photoresistor (LDR)Common build supply
- 10 kΩ threshold potentiometerCommon build supply
- 10 kΩ resistorCommon build supply
- 2N2222 NPN transistorCommon build supply
- LEDCommon build supply
- 330 Ω resistorCommon build supply
- 100 nF capacitorCommon build supply
- breadboardCommon build supply
- regulated 5 V supplyCommon build supply
Amazon links may be affiliate links. As an Amazon Associate, Electronics Hobby Hub earns from qualifying purchases.
Connections
- Power LM358 pin 8 from +5 V and pin 4 from ground; bypass supply with 100 nF.
- Make a divider from +5 V through 10 kΩ to a sense node, then through the LDR to ground; connect the sense node to pin 3. The sense voltage rises as the room gets darker.
- Wire the 10 kΩ potentiometer between +5 V and ground; connect its wiper to pin 2 and adjust the threshold.
- Connect pin 1 through 4.7 kΩ to the 2N2222 base. Emitter to ground; collector to LED cathode. LED anode goes through 330 Ω to +5 V.
Build steps
- Build and inspect the LDR divider before inserting the op amp.
- Add the potentiometer reference and compare its voltage with the LDR sense voltage.
- Add the transistor as the LED switch; do not ask the op amp output to drive a high-current load.
- Shade the LDR and adjust the potentiometer until the LED changes state at the desired light level.
Software and firmware setup
This is a hardware-only circuit; no firmware is required.
Test your build
Cover the LDR to simulate darkness and expose it to a lamp to simulate daylight. The LED should switch near the threshold you set.
Troubleshooting
- If the response is reversed, swap the pin 2 and pin 3 inputs.
- If the LED is always on, check transistor pinout and LDR divider polarity.
- If it flickers around the threshold, add a small 10–100 kΩ feedback resistor from pin 1 to pin 3 for hysteresis, then retune.
Safety and limitations
Use only a low-voltage LED circuit. This is a demonstration, not a mains light controller.
Manufacturer and platform documentation
Community Notes for This Project
These are unverified visitor contributions, separate from the build guide and manufacturer specifications. Verify technical advice against the linked datasheets before relying on it.
Set up the comments service to load community notes.