Automatic Night Light (LDR)
A photoresistor (LDR) and a BC547 transistor turn an LED on when it gets dark. No code or microcontroller involved.
Bill of materials
Everything you need to build it, with the reference you will see on the schematic.
| Qty | Part | Ref. |
|---|---|---|
| 1 | 100 kΩ resistor (brown-black-yellow) | R1 |
| 1 | GL5528 photoresistor (LDR) | LDR1 |
| 1 | BC547 NPN transistor | Q1 |
| 1 | 470 Ω resistor (yellow-violet-brown) | R2 |
| 1 | yellow LED | D1 |
| 1 | 9 V battery with snap clip | BT1 |
| 1 | Breadboard (400 tie-points or more) | |
| 4 | Jumper wires |
Missing parts? The kits recommended by Impeca Tech include almost all of them. See the kits
Schematic & wiring
On the left, the circuit diagram; on the right, the same circuit built on a breadboard. Both connect exactly the same things.
Wire it step by step
-
Place the components
- 100 kΩ resistor R1 (bands: brown, black, yellow, gold): one leg in 6f and the other in 3f (either way round).
- Photoresistor (LDR) LDR1: one leg in 3h and the other in 5h (either way round).
- BC547 transistor Q1 with the flat face (the one with the text) towards you, left to right: collector (C) in 10f, base (B) in 11f, emitter (E) in 12f.
- 470 Ω resistor R2 (bands: yellow, violet, brown, gold): one leg in 6g and the other in 9g (either way round).
- yellow LED D1: the long leg (+, anode) in 9h and the short leg (−, cathode, flat side) in 10h.
-
Add the jumper wires
- Red wire: from 6j to the + (red) rail.
- Orange wire: from 3j to 11j.
- Black wire: from 5j to the − (blue) rail.
- Black wire: from 12j to the − (blue) rail.
-
Connect the battery
- Connect the 9 V battery to its clip: the clip’s red lead to the + (red) rail and the black one to the − (blue) rail. Do this last, once everything else is in place.
-
Test the circuit
- In normal room light the LED should be off. Cover it well (with cupped hands or a thimble): the LED lights. Take your hand away and it goes off. If it always seems on or always off, the threshold depends on the light in your room: try with more or less light.
How to read the holes: the letter is the row and the number is the column of the breadboard (for example 7f). The red (+) and blue (−) rails are the two long lines along the edge.
How does it work?
- 1Low light
- 2LDR: high resistance
- 3Transistor conducts
- 4LED turns ON
The photoresistor (LDR) and resistor R1 form a voltage divider. When it gets dark, the LDR’s resistance increases sharply (from about 15 kΩ at 10 lux to hundreds of kΩ in darkness), raising the voltage at the base of the BC547 transistor and allowing current to flow to light up the LED. In bright light the LDR drops to a few kΩ and holds the base near 0 V: the transistor is cut off and the LED is off. R2 limits the LED current to about 14 mA.
Testing & troubleshooting
What you should see
- Daylight (1000 lux)
- LED currentunder 1 µA
- Lit room (200 lux)
- LED currentunder 1 µA
- Dim light (3 lux)
- LED current≈ 14 mA
- Darkness (0.1 lux)
- LED current≈ 14 mA
Approximate values, calculated with typical parts. With real parts they can vary by 10 % or more.
If something does not work
Is the LED always ON?
Check the pinout orientation of the BC547 transistor (Collector, Base, Emitter) and the LED polarity. Also check that the LDR sits between the base and GND, not between the base and +.
The LED does not light even in the dark?
Check that R1 is 100 kΩ (brown-black-yellow). With a much lower value the base never rises enough. Make sure it is really dark: a sliver of light is enough to keep it off.
Want to automate this circuit with code?
Learn how to program sensors and custom schedules in our e-book “Arduino from Scratch”.