Project: night light
Project: a night light
Build a light that switches itself on when the room goes dark.
| Requirement | |
|---|---|
| Lights | three LEDs, each with a 470 Ω resistor |
| Dark | all three on |
| Room light | all three off |
| Power | one 9 V battery, about 500 mAh |
An LDR divider can sense the dark, but it can't drive three LEDs: it would sag the moment they drew current from it. So between the two goes a switch block, already on the board. Inside is a transistor, which you'll meet properly later. For now, its datasheet is all you need:
- IN above 2 V: OUT is joined to GND, so anything wired from the + rail to OUT turns on.
- IN below 2 V: OUT is open, and nothing flows.
- IN takes almost no current.
So the divider's output needs to be high in the dark. Which way up should it go?
- Fixed resistor on top, light sensor at the bottom
- Light sensor on top, fixed resistor at the bottom
Build the dark detector: a fixed resistor from the + rail to the block's IN (column 24, this side of the gap), and the light sensor from IN to the − rail.
Pick the fixed resistor so IN is well above 2 V at night and well below it in room light. Test it with the sensor's light slider and the meter.
Now the lights. Three LEDs, each with its own 470 Ω resistor, from the + rail. Instead of going to the − rail, each LED's − leg goes to the block's OUT (column 24 on the far side of the gap), so the block switches all three at once.
Slide the sensor to dark and to light to test it.
Now the power budget: how long will the battery last through the night?
At night, the battery supplies the three LEDs, plus a trickle through the divider. Measure the battery's current at night (set the sensor to dark, and put the meter on amps in series with the battery's + lead), or add it up from Ohm's law.
The battery holds about 500 mAh. How many hours of darkness will it light?
Answer in h.
You'd like it to last a week of nights on one battery. What's the most effective change?
- Raise the LED resistors, say to 2.2 kΩ: a quarter of the current, still clearly lit
- Use a bigger fixed resistor in the divider
- Add more LEDs in parallel
Your night light:
- an LDR divider, fixed resistor on top, so its output rises in the dark;
- a switch block that turns the LEDs on when its input passes 2 V, and draws almost nothing itself;
- three LEDs, each with its own resistor, switched together;
- a power budget: about 43 mA at night, about 11½ hours from a 9 V battery.
You've used a transistor without knowing how it works. The transistors course opens the block.