BeginnerLighting

Dark-Activated Night Light

Use an LM358 as a light-level comparator so an LED turns on when the room gets dim.

Estimated time: 45–60 minutes · Skills: Voltage dividers, comparator thresholds, transistor switching

Parts from the database

Other supplies

Amazon links may be affiliate links. As an Amazon Associate, Electronics Hobby Hub earns from qualifying purchases.

Connections

  1. Power LM358 pin 8 from +5 V and pin 4 from ground; bypass supply with 100 nF.
  2. 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.
  3. Wire the 10 kΩ potentiometer between +5 V and ground; connect its wiper to pin 2 and adjust the threshold.
  4. 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

  1. Build and inspect the LDR divider before inserting the op amp.
  2. Add the potentiometer reference and compare its voltage with the LDR sense voltage.
  3. Add the transistor as the LED switch; do not ask the op amp output to drive a high-current load.
  4. 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.

Share a tip or question about this build

← Browse all projects