Level 3 · Sense · project 7 of 12 · 25 min · ●●●○○
Vacation Nightlight
The Automatic Night Light with a manual override — flip the slide switch off and the lamp stays dark even in a pitch-black room.
new here? Start with First Light — one battery, one resistor, one LED. It teaches the loop, LED direction, and why the 220 Ω resistor matters.
What you need
- 1× 3×AA battery pack (4.5 V) L1
- 1× Solderless breadboard L1
- 7× Jumper wires L1
- 1× Light sensor (LDR) the "eye" — bottom of the divider, same as Automatic Night Light
- 1× 10 kΩ resistor top of the sensing divider — the room-detector L1
- 1× 1 kΩ resistor protects the transistor base L1
- 1× NPN transistor (2N2222) flat face toward you: legs are E-B-C
- 1× Red LED (5 mm) the lamp — long leg toward plus L1
- 1× 220 Ω resistor LED lane speed bump L1
- 1× Slide switch the manual override — sits in the LED lane, not the sensor lane L1
you'll learn: Voltage dividers · Transistor switching · Switches · Ohm's law
Circuit map
The circuit you'll build, running on the Workbench right now — shown with the lights off.
simulating…
If it doesn't work
The boring ways this circuit actually breaks — check these first before you unwire everything.
- Off slide doesn't stop the lamp. The slide should sit in series with the shared + rail (or in the LED lane). If it only touches the sensor divider, it can't stop the lamp downstream of the transistor.
- Lamp never comes on in the dark. 2N2222 pins E-B-C (flat face toward you), then confirm the LDR is on the BOTTOM of the sensing divider.
- Lamp always on in daylight. Divider is flipped, or the off slide is stuck closed by a bad wire.
- LED very dim when on. Wrong resistor in the LED lane. 220 Ω = red-red-brown.
- Slide toggles but nothing changes. Middle leg + one outer leg on the slide.
What you're building
The Automatic Night Light did one job well: it decided for you. Cover the sensor, lamp on; bright room, lamp off. Great — until the weekend you go away and want the lamp off, no matter what. Or the day you're painting the room and hover a bright work light over the sensor and the lamp keeps flickering.
The fix is a small, human one: give the lamp an override. Flip a slide switch on and it works exactly like Automatic Night Light. Flip it off and the lamp stays dark, even when the room is pitch black. The sensor is still watching — it just can't win against your finger.
Real streetlights and hallway sensor lights all have this. Somewhere inside every one is a small three-position selector: auto, always-on, always-off. You're building the "auto / always-off" half of it now.
The big idea: override in one lane
The Automatic Night Light has two halves — a sensing half (the divider on the left) and a deciding + output half (the transistor plus the LED lane on the right). They meet at one place: the base of the transistor.
The trick is to break only the output half and leave the sensing half untouched. That way the sensor keeps sipping its microamps and staying alert, but the LED can't fire because its lane is broken somewhere.
The cleanest place to break the output half is right at its entry from the + rail — before the 220 Ω speed bump. Insert the slide switch there:
- + rail → SLIDE SWITCH → 220 Ω → LED → transistor collector → transistor emitter → − rail.
- The sensing half is unchanged: + rail → 10 kΩ → middle → LDR → − rail, and middle → 1 kΩ → base.
Slide switch open? The + rail can't reach the 220 Ω, so no current can enter the LED lane no matter how hard the transistor tries to open its gate. Lamp dark.
Do the math (three modes)
Auto mode, bright room (switch closed, LDR ≈ 1 kΩ):
- Divider middle = 4.5 × 1 ÷ (10 + 1) = 0.41 V
- 0.41 V is below the 0.7 V wake-up line → transistor off → LED off even though the switch is closed.
- Battery current: only the divider is alive, drawing 4.5 ÷ 11 kΩ ≈ 0.4 mA. Fresh AAs stay fresh for a very long time.
Auto mode, dark room (switch closed, LDR ≈ 100 kΩ):
- Divider middle tries for 4.5 × 100 ÷ 110 = 4.1 V, but the base clamps it around 1 V. Base voltage crosses 0.7 V → transistor on.
- LED lane: 4.5 − 2.0 (red LED) − 0.2 (V_CE(sat)) = 2.3 V across the 220 Ω → I_LED = 2.3 ÷ 220 ≈ 10 mA. Comfortable glow.
- Battery current: LED lane ≈ 10 mA plus a trickle from the sensing half. Call it ~11 mA total.
Vacation mode, dark room (switch open):
- The + rail cannot reach the LED lane. I_LED = 0. Lamp dark.
- The sensing half is still alive — divider middle at whatever value the LDR chooses, base above 0.7 V, transistor collector "ready" — but nobody is bringing collector current to the party. The transistor doesn't force current, it permits it.
- Battery current: only the sensing half — 0.4 mA. That's the vacation-mode power budget. Two weeks unattended is nothing.
Notice what didn't happen when you opened the switch: the divider didn't stop working, the base didn't get hot, the transistor didn't complain. Breaking a fixed load's loop is completely harmless, because the load is what asks for current in the first place.
Build it
If your Automatic Night Light is already on the breadboard, this is a two-wire change. Slide the top-rail jumper that feeds the LED lane's 220 Ω up one row, and drop a slide switch between the + rail and the row it now lands on. Everything else stays put.
Fresh build:
- Power rails: battery + to a top row, battery − to a bottom row.
- The sensing half (untouched from Automatic Night Light): + rail → 10 kΩ → sensing middle row → LDR → − rail.
- The base link: sensing middle row → 1 kΩ → transistor Base (middle leg, flat face toward you).
- The transistor (untouched): Emitter (left leg) → − rail. Collector (right leg) → LED lane.
- The override + LED lane: + rail → slide switch → LED-lane top row → 220 Ω → LED long leg → LED short leg → transistor Collector.
- Cover the LDR with the switch on: lamp glows on. Cover the LDR with the switch off: lamp stays dark. Uncover the LDR with the switch on: lamp goes dark. Every combination should agree with the table above.
Why put the switch there?
Two other places you could put it — and why the LED-lane spot is the best of the three:
- In series with the LED itself (between LED and collector): works, but you're now handling the same current the LED sees. On 4.5 V it's fine, but the general habit — put the switch as far upstream as possible — protects fancier future switches from bigger loads.
- In series with the 1 kΩ base resistor (breaking the base drive): also works! Open the switch → no base current → transistor off → LED off. But now the transistor is fully off rather than the LED lane being open, and there's no way to tell from the wall that "vacation mode" is actually a mode versus "the sensor is broken". Putting the switch in the LED lane keeps the sensor's behaviour visible if you ever add a scope, and it matches how hallway sensor lights actually work.
The lesson: there is usually more than one right answer in electronics, and picking between right answers is a real skill. The best answer often depends on what you're going to do next with the circuit.
🧠 Your challenge
No single right answer. That's the point.
- Always-on mode. Add a second slide switch that jumps straight from + rail to the LED lane's top row, bypassing the transistor entirely. Now you have three states: auto (new switch off, override switch on), always-off (override switch off), and always-on (both switches on). Draw the state table before you build it.
- Move the override. Rebuild it with the slide switch in the base drive path (between the 1 kΩ base resistor and the base itself) instead of in the LED lane. Verify it still works. Which of the two positions makes more sense if you later add a buzzer lane too, so the buzzer always fires in the dark but the lamp is optional?
- Two-lane override. Rewire the output half to fire both a red LED and a buzzer in the dark, with your slide switch cutting only the LED lane. Now vacation mode is "silent but still alerts" — useful for a pet dish sensor that beeps for you but doesn't wake the family.
- Predict the current draw of vacation mode from the numbers in the article above. Then, if you have a multimeter, measure it in series with the battery. Does it match the ~0.4 mA prediction? (If your reading is much higher, one of the switch legs is probably shorting to a rail — walk the wiring.)
For grown-ups: safety notes
- Battery-safe throughout. Even in auto mode with the lamp firing at ~10 mA, total battery current sits near 11 mA. Vacation mode drops that to ~0.4 mA — a set of AAs will outlast the vacation.
- Do not put the override in a shared power rail (between the battery and both halves at once). That would kill the sensor too, which is fine electrically but pointless — a fully-off circuit doesn't need a fancy override. This project is only interesting because the sensor stays alert while the lamp is disabled.
- If the transistor warms up in vacation mode, disconnect the battery and re-check E-B-C leg order (flat face toward you). A backwards transistor draws current through the base into the emitter regardless of the LED lane switch, and it will heat.
- If the lamp lights softly even with the switch off, the slide switch has probably been wired between its two outer legs instead of middle + one outer — those outer legs are never connected to each other, so "open" and "closed" both look the same. Wire middle → outer and try again.
- Leave the finished project on a hard surface, not on bedding or carpet, even overnight. Everything on this site is safe to run unattended, but airflow is a good habit for later projects with bigger currents.
Checked against
Keep building
You might also like
shares ideas with this one