A simple automatic night lamp circuit using an LDR walkthrough — components, circuit connections, working principle, light detection, wiring steps, and an interactive automatic night lamp system you can explore in the browser.
Sensor electronics · LDR + transistor
The whole circuit is one idea: an LDR's resistance changes with light, so wire it into a divider and the divider's output changes with light too. Everything after that is just amplifying "it's dark" into "switch the lamp on."
Tap the LDR to cover it and watch the lamp respond
Status: daylight — lamp off
Parts bin
One sensor, one transistor stage, one relay. Nothing here needs power beyond a low-voltage bench supply — the relay is what lets it switch a real lamp safely.
Operating principle
An LDR doesn't switch anything by itself. It just changes resistance — everything else in the circuit exists to turn that change into a decision.
An LDR behaves like an ordinary resistor whose value depends on how much light hits it — typically a few hundred ohms in bright light, rising to hundreds of kilohms in darkness. Pair it with RV1 in a potential divider and the voltage at their midpoint tracks the light level directly: high in daylight, low in the dark, or the reverse depending on which one sits on top.
Here the LDR sits on top, so darkness is what lets that midpoint voltage rise. Once it's high enough to forward-bias Q1's base-emitter junction, the transistor turns on and pulls current through the relay coil, closing the switch that feeds the lamp.
The relay exists because the lamp draws far more current, and often runs on a different voltage entirely, than the low-power sensing circuit could ever supply directly. The transistor switches a few milliamps into the coil; the coil's contacts switch the lamp.
RV1 isn't optional trim — it's the only thing setting the threshold. Without it, the circuit only responds correctly to whatever light level the LDR happens to be calibrated for.
D1 isn't protecting the lamp, it's protecting Q1. A relay coil is an inductor, and switching it off makes it briefly fight back with a reverse voltage spike — the diode gives that spike somewhere to go besides through the transistor.
Swap the LDR and RV1's positions in the divider and the whole circuit inverts: lamp on in daylight, off at night. It's a one-wire change either way.
Assembly
Five steps — check the divider voltage with a meter before the transistor goes in, so you know the sensing half works on its own.
Run the LDR from +V down to a middle node, then RV1's wiper from that same node down to ground. In bright light the LDR's resistance is low, so that middle node sits close to ground. In the dark, its resistance climbs and the node is pulled up toward +V instead.
Run R1 from the LDR/RV1 junction to Q1's base. Tie the emitter to ground. This resistor is just current protection — the divider has already done the actual sensing, deciding whether the base sees enough voltage to turn Q1 on.
RV1 decides how dark "dark" needs to be. Turning it one way makes the lamp switch on at dusk; the other way holds it off until it's nearly black outside. There's no fixed setting — it's tuned by eye once the rest of the circuit works.
Put the relay coil between +V and Q1's collector, so the transistor switches the coil to ground when it turns on. Place D1 across the coil, cathode toward +V, before you power anything up — without it, the coil's collapsing field can spike back and damage Q1 the first time it switches.
Connect the lamp through the relay's normally-open contact. Power up in daylight — lamp off. Cover the LDR with your hand or a finger — the relay should click and the lamp should come on. Uncover it and it should drop out again within a second.
If it misbehaves
Almost every fault here traces back to the divider — which part is on top, and where RV1 is set.