Home
LogicRoo / Combinational Gates / Automatic Night Lamp Circuit Using LDR — Smart Light | Logicroo

Automatic Night Lamp Circuit Using LDR — Smart Light | Logicroo

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

No switch, no clock —
just a resistor that sees.

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."

1Sensor
1Transistor
1Relay
6–9VTypical supply
Tap the LDR to cover it and simulate nightfall →
SCH-07 · LDR_NIGHT_LAMP lamp off
6–9V LDR1 light sensor ~0.4V RV1 10k sensitivity R1 1k Q1 BC547 RL1 relay coil D1 relay contacts NO NC LAMP R2 220Ω LED1

Tap the LDR to cover it and watch the lamp respond

Status: daylight — lamp off


Parts bin

What you need

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.

×1 LDR (Light Dependent Resistor) LDR1
×1 10 kΩ Trim Potentiometer — sensitivity RV1
×1 BC547 NPN Transistor Q1
×1 1 kΩ Resistor — base current limit R1
×1 6V/9V Relay, SPDT RL1
×1 1N4007 Diode — relay flyback D1
×1 LED + 220 Ω Resistor — lamp indicator LED1, R2
×1 Lamp or Bulb (switched by the relay) LAMP
×1 Breadboard BASE
×— Jumper Wires BASE
×1 6–9V Supply PWR

Operating principle

Turning "dark" into a voltage

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.

Two components most people skip

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

Building it on a breadboard

Five steps — check the divider voltage with a meter before the transistor goes in, so you know the sensing half works on its own.

Build the light-sensing divider

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.

Feed that node into the transistor base

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.

Set the threshold

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.

Add the relay and its flyback diode

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.

Wire the lamp to the relay's switched contact

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

Always on, never on, or backwards

Almost every fault here traces back to the divider — which part is on top, and where RV1 is set.