Daylight-Activated Switch
The opposite of a night light: the LED lights when there is light and goes off in the dark, using an LDR and a BC547 transistor.
Bill of materials
Everything you need to build it, with the reference you will see on the schematic.
| Qty | Part | Ref. |
|---|---|---|
| 1 | GL5528 photoresistor (LDR) | LDR1 |
| 1 | 1 kΩ resistor (brown-black-red) | R3 |
| 2 | 470 Ω resistor (yellow-violet-brown) | R1, R2 |
| 1 | BC547 NPN transistor | Q1 |
| 1 | green LED | D1 |
| 1 | 9 V battery with snap clip | BT1 |
| 1 | Breadboard (400 tie-points or more) | |
| 5 | 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
- Photoresistor (LDR) LDR1: one leg in 3f and the other in 5f (either way round).
- 1 kΩ resistor R3 (bands: brown, black, red, gold): one leg in 5h and the other in 8h (either way round).
- 470 Ω resistor R1 (bands: yellow, violet, brown, gold): one leg in 8f and the other in 11f (either way round).
- BC547 transistor Q1 with the flat face (the one with the text) towards you, left to right: collector (C) in 13f, base (B) in 14f, emitter (E) in 15f.
- 470 Ω resistor R2 (bands: yellow, violet, brown, gold): one leg in 9h and the other in 12h (either way round).
- green LED D1: the long leg (+, anode) in 12i and the short leg (−, cathode, flat side) in 13i.
-
Add the jumper wires
- Red wire: from 3j to the + (red) rail.
- Red wire: from 9j to the + (red) rail.
- Orange wire: from 8j to 14j.
- Black wire: from 11j to the − (blue) rail.
- Black wire: from 15j 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
- Hold the LDR near a window or a lamp: the LED should light. Cover it with your hand: it goes off. In very dim light the threshold can be a little vague; that is normal in such a simple circuit.
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?
- 1There is light
- 2LDR: low resistance
- 3The base gets voltage and the transistor conducts
- 4The LED turns ON
Here the LDR sits between the positive and the base, with R1 between the base and GND, so the divider is the opposite way round to the night light. In bright light the LDR’s resistance is low (about 1 kΩ at 1000 lux): the base gets enough voltage and current and the transistor conducts. In darkness the LDR’s resistance is huge, the base current almost vanishes and the LED goes off. R3 protects the base from excessive current.
Testing & troubleshooting
What you should see
- Bright light (1000 lux)
- LED current≈ 15 mA
- Window light (300 lux)
- LED current≈ 15 mA
- Dim light (10 lux)
- LED currentunder 1 µA
- Darkness (0.1 lux)
- LED currentunder 1 µA
Approximate values, calculated with typical parts. With real parts they can vary by 10 % or more.
If something does not work
The LED is on even in the dark?
Check that the LDR is between + and R3, not between the base and GND, and that R1 (470 Ω) goes from the base to GND. If you swapped them you have built the night-light circuit.
The LED is very dim in normal light?
In dim light the LDR still has a high resistance and the transistor only half conducts. Increase the light on the sensor or try a phone torch.
Want to automate this circuit with code?
Learn how to program sensors and custom schedules in our e-book “Arduino from Scratch”.