Skip to content
LearnTronics menu

LearnTronics

Automatic Nightlight with Delay

Tutorial Index

Recipe #25 — automatic nightlight with delay

The light-controlled switch can be improved by adding capacitance. An LDR senses darkness, a capacitor slows rapid changes, and a comparator makes a clean decision.

AUTOMATIC NIGHTLIGHT WITH RC DELAY +9 V P1 — DARK SET LDR C1 — DELAY + +9 VR2R3 RB +9 VNIGHT LED C1 slows the sense-voltage change so passing shadows do not make the light chatter.
Bright: the LDR has low resistance and pulls the sense voltage down. Dark: LDR resistance rises, the sense voltage rises, and after C1 has charged far enough the comparator turns the nightlight on.

Why add C1?

Without C1, a brief shadow or flicker can move the sense voltage across the threshold immediately. C1 slows that change. The nightlight therefore responds to a sustained change in light rather than every tiny disturbance.

Delay and hysteresis solve different problems

An RC delay slows changes with time. Comparator hysteresis creates separate ON and OFF thresholds. Practical sensor switches often use both so they neither react too quickly nor chatter near the switching point.

Try these yourself

What happens to a typical LDR resistance when the room becomes darker?
A typical LDR has higher resistance in darkness.
What is C1 doing in this nightlight?
C1 slows changes at the sensor node so short light changes are less likely to switch the output.
What control sets the darkness level at which switching occurs?
P1 adjusts the sensor divider and therefore the darkness threshold.