Intermediate · Project 3
Night Light
Build a light that switches itself on when it gets dark, using a light sensor and two transistors.
Build this only with an adult present. Before you start, read our safety notice and disclaimer.
🧰 What you need
- 1×Half-size breadboardA board full of little holes with metal clips inside, so you can build circuits without soldering.
- 1×3×AA battery holder with wire leadsHolds three AA batteries in a row and gives you a red (+) and black (−) wire.
- 3×AA batteryA regular household battery. Each one gives 1.5 volts.
- 1×Light sensor (LDR / photoresistor)A resistor that changes with light: lots of resistance in the dark, little in bright light.
- 1×100 kΩ resistor — brown, black, yellow, goldColors: brown, black, yellow, gold.
- 2×2N3904 transistor (NPN)A tiny electronic switch: a small current into its middle leg (base) controls a bigger current.
- 1×220 Ω resistor — red, red, brown, goldOur go-to LED resistor. Colors: red, red, brown, gold.
- 1×5 mm LED (any color) — yellow or white looks cozyA tiny light that only lets current flow one way. The long leg is +.
- 7×Jumper wireA short wire with stiff ends that push into the breadboard.
✨ The finished project
🔣 New schematic symbols
This project’s schematic has some symbols you haven’t seen before. Here’s what they mean.
- Light sensor (LDR)
A resistor in a circle, with arrows pointing IN: light falling on it. The more light, the lower its resistance.
Streetlights turn on by themselves at dusk. How do they know it’s getting dark? A light sensor! In this project you’ll build your own automatic night light.
Meet the light sensor (LDR)
An LDR (light-dependent resistor, or photoresistor) is a resistor whose value changes with light:
- In normal room light: about 8 kΩ–20 kΩ.
- In the dark: 200 kΩ or much more!
The squiggly line on top is a special material that lets more current through when light shines on it.
The voltage divider trick
The 100 kΩ resistor and the LDR are connected one after the other between + and −, and the point between them goes to the transistors. They share the battery’s 4.5 V like a tug-of-war:
- Light: the LDR is small, so it “wins” and pulls the middle point down to about 0.8 V. That’s not enough to turn the transistors on.
- Dark: the LDR is huge, so the 100 kΩ resistor wins and pulls the middle point up to about 3.0 V or more. That’s plenty: the transistors switch on and so does the LED!
This is called a voltage divider, and it’s one of the most useful tricks in electronics. The two transistors are a Darlington pair, like in the Touch Switch, so they need about 1.3 V to switch on.
Build it
Transistor Q1: flat side facing you, E e4, B e5, C e6.
Transistor Q2: flat side facing you, E e9, B e10, C e11.
Blue wire: b6 to b11, joining the two collectors.
Black wire: a9 (Q2’s emitter) to T-9 (top blue − rail, column 9).
100 kΩ resistor: stand it up between a5 (Q1’s base column) and T+5 (top red + rail, column 5).
Yellow wire: b5 to b3.
Light sensor: legs in e3 and e1. It has no + or −, so either way round works. Then a black wire from a1 to T-1 (top blue − rail, column 1).
Blue wire: a11 (the collectors) to a14.
LED: short leg in e14, long leg in e15. Then the 220 Ω resistor from b15 to b19, and a red wire from a19 to T+19 (top red + rail, column 19).
Power: battery red into T+1, black into T-2. In a lit room the LED stays off. Now cover the light sensor with your hand, and the light comes on! 🌙
Not working?
- LED on all the time? Your room might be quite dim. Shine a flashlight on the sensor. If it goes off, it’s working, just very sensitive. For a less sensitive light, swap the 100 kΩ for 47 kΩ.
- Never comes on? Cover the sensor completely (cup your hand tightly over it). Check both transistors are the right way round.
- Test the LED part: put a jumper wire from Q1’s base column (a5) to the + rail. The LED should light.