Level 3 · Sense · project 16 of 17 · 30 min · ●●●○○

Alley Lamp

Automatic Night Light with a push-button override. Dark room OR button press fires the lamp — a wired-OR built straight onto the transistor's base.

new here? Start with First Light — one battery, one resistor, one LED. It teaches the loop, LED direction, and why the 220 Ω resistor matters.

You'll make a night light with a daytime override
You'll learn two pull-ups into one node is an OR gate
Watch for the override has its OWN 1 kΩ — don't share it with the base resistor

What you need

🔧 Try before wiring →

you'll learn: Voltage dividers · Transistor switching · Series & parallel · Ohm's law · LED polarity · Switches

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.

  • Lamp stays on all the time, even in daylight with the button up. You wired the override 1 kΩ in parallel with the 10 kΩ permanently — the push button got left out. Trace: the 1 kΩ pull-up must be downstream of the button, so the branch is only live when the button is pressed.
  • Lamp never fires, even in a pitch-dark room. Transistor pin scramble — base to collector likely swapped. Flat face toward you, legs are E-B-C left to right. Base goes to the 1 kΩ base resistor, collector to the LED's short leg, emitter to the − rail.
  • Button override fires the LED in daylight only briefly, then it goes dark. The 1 kΩ override resistor is actually a 10 kΩ (or you swapped them with the top divider's 10 kΩ). V_middle lands at the wake-up edge in bright light. Colour bands: brown-black-red = 1 kΩ; brown-black-orange = 10 kΩ.
  • LED fires in daylight even with the button up, but goes OFF when you cover the sensor. The LDR is in the override branch, or the LDR is on TOP of the divider instead of the bottom. The LDR should sit between the middle node and the − rail; the 10 kΩ sits between + and the middle node.
  • Button press makes a buzzing noise or the circuit flickers. Loose jumper on the override branch — the button isn't making solid contact. Reseat the button and check the 1 kΩ is firmly in its row. Also check battery contacts.
  • LED is a dim pinprick instead of First-Light bright. The 220 Ω speed bump is actually a 1 kΩ or a 10 kΩ. Colour bands: brown-black-red = 220 Ω. The 220 Ω belongs in the LED lane; the two 1 kΩs belong in the base path and the override branch.
  • Button override fires the lamp, but it stays on after you let go. You wired a slide switch instead of a push button, or the push button's internal contacts are stuck. A momentary push button only closes while held — releasing should snap the override off.

What you're building

A night light that also acts like an ordinary lamp. During the day the sensor sees sunlight and keeps the LED off — standard Automatic Night Light behaviour. At night the sensor sees darkness and the LED fades on by itself. The new trick: if you'd rather have the lamp on now, in the middle of the day, hold the override button. The LED comes up as if it were midnight. Release the button and the lamp goes back to listening to the sensor.

Alleys and stairwells use this exact pattern. The light runs on a dusk-dawn sensor so no one has to flip a switch at sunset, but there's a manual button next to the door for when the sun's still up but the hall is dark enough that you want the light anyway. One lamp, two reasons to turn it on, joined with an OR.

The big idea: two paths to the same base

So far every L3 project you've built had one input moving the transistor's base — the LDR (or the thermistor, or a trip-wire pull-up). Alley Lamp adds a second input: the push button, through its own 1 kΩ resistor, pulling the base-divider's middle node up toward +.

Both paths push the same middle node toward +. Either one is enough to saturate the transistor. The circuit doesn't know (or care) which one did it — current is current, and voltage above the 0.7 V wake-up line is above the 0.7 V wake-up line.

The result is a hardware OR gate — the LED fires if dark OR button-pressed. No logic chip, no code, just a resistor summing two currents into one node.

The sensing half — unchanged from Automatic Night Light

Divider: 10 kΩ on top, LDR on the bottom, middle node drives the 1 kΩ base resistor. If this is new, read Automatic Night Light first.

  • Bright room, LDR ≈ 1 kΩ: V_middle = 4.5 × (1 ÷ 11) ≈ 0.41 V. Below the 0.7 V wake-up. Transistor off. LED dark.
  • Dark room, LDR ≈ 100 kΩ: V_middle tries to climb toward 4.5 × (100 ÷ 110) ≈ 4.1 V. Base-emitter junction clamps it to ~0.9 V and drinks the extra push. Transistor saturated. LED on at ~10 mA.

The new piece — the override branch

Add a second path from + to the middle node, this one gated by a push button and sized by a 1 kΩ resistor:

+ → push button → 1 kΩ → middle node

When the button is up, that branch is broken — the circuit behaves exactly like Automatic Night Light.

When the button is down, the 1 kΩ sits in parallel with the 10 kΩ above the middle node. Two resistors in parallel combine as smaller than either alone:

R_top_effective = (10 kΩ × 1 kΩ) ÷ (10 kΩ + 1 kΩ) ≈ 909 Ω

The LDR is still 1 kΩ in bright light. New divider arithmetic:

V_middle = 4.5 × (1 ÷ (0.909 + 1)) ≈ 2.36 V

That's well past the 0.7 V wake-up line. The transistor saturates. The LED lights at ~10 mA — same brightness as the automatic nighttime glow, triggered by hand instead of by the sun.

Press the button at night: V_middle climbs even higher (two pull-up paths from +, one single tiny pull-down through the 100 kΩ LDR). The lamp was already on, so you see nothing change. The circuit's answer is "I was already going to do that, thanks".

The truth table — OR behavior

Four input combinations, three "LED on" outcomes:

LDR says Button V_middle Transistor LED
bright up 0.41 V off dark
bright down ~1.9 V (clamped by base) saturated on at ~10 mA
dark up ~1.2 V (clamped by base) saturated on at ~10 mA
dark down even higher, clamped same saturated on at ~10 mA

Only the first row — bright AND button-up — keeps the LED off. Any one input is enough to light it. That's an OR gate, in resistor- and-transistor form.

Why 1 kΩ in the override, not 10 kΩ?

The override path needs to pull the middle node high enough to cross the 0.7 V wake-up line. If you used a second 10 kΩ as the override resistor, parallel with the top 10 kΩ, R_top_effective would be 5 kΩ, and in bright light V_middle would be 4.5 × (1 ÷ 6) ≈ 0.75 V — right at the wake-up edge. The LED might flicker on, might not. Reliability is 1 kΩ's job here: a strong enough pull-up to leave no ambiguity about which side of the threshold the circuit lands on.

If you used something smaller than 1 kΩ (say 220 Ω), the base current when the button is held would climb — (4.5 − 0.9) ÷ 220 ≈ 16 mA into the base. Enormous, inefficient, and makes the button hot after a while. 1 kΩ is the sweet spot.

Where OR gates on a transistor base show up

  • Hall lamps with a dusk sensor + "turn on now" wall button — this exact circuit, in every modern US apartment building that predates smart bulbs.
  • Garage lights that fire on either the motion sensor or the door-open switch — two inputs ORed into a single relay or transistor driver.
  • Car headlights that come on either because the auto-light sensor says it's dark or because you pulled the stalk — the manual switch and the sensor both drop the same signal to the lamp relay.

An AND wants everything to agree; an OR is permissive — "any reasonable input is enough". This is the first project on this site where you've built an OR without needing more than resistors and a transistor you already own.

🧠 Your challenge

No single right answer. That's the point.

  • AND instead of OR — a daylight-only lamp. Rebuild the circuit so the LED only fires when the room is dark AND the button is pressed. (That's the Night Doorbell pattern — move the push button to the + rail of the LED lane, in series with the 220 Ω speed bump. Now the button gates the collector lane, and the LDR gates the base. Both have to agree. Compare the two: the OR lives on the base, the AND lives on the collector.)
  • A second override from a slide switch. Add a slide (if you have one spare, otherwise swap in the one from your box) in parallel with the push button + 1 kΩ branch. Now the lamp fires if dark OR a momentary button OR a latched slide — a three-way OR. Which input would you use for what? (Slide = "keep this on", button = "right now for a second", LDR = "evening". The real-world pattern most alley lamps actually use.)
  • Shrink the override — a weak pull-up. Replace the 1 kΩ override resistor with a 10 kΩ. Does the override still work? Try it. (V_middle in bright + button = 4.5 × (1 ÷ (5 + 1)) = 0.75 V, right at the wake-up edge. The LED either barely glows or stays dark. This is why resistor sizing matters — the OR gate only "votes yes" if the pull-up is strong enough.)
  • A dimming override. Put the 10 kΩ pot (if you have one from Level 2) in place of the override 1 kΩ. Twist the knob while holding the button in daylight. (At knob = 0, same as the normal override. At knob = ~5 kΩ, the pull-up weakens: V_middle sits around 0.7 V — the LED fades in and out through the mush zone. At knob = max, the override is too weak to fire the LED. You've built an override with "sensitivity".)
  • Why does pressing the button at night not change anything visible? Trace the base node with your eye. (V_middle was already clamped at ~0.9 V by the base-emitter junction. Adding a second pull-up path doesn't move V_middle — it only increases the base current the transistor sucks down. The collector lane sees the same V_CE_sat and the same 10 mA LED current. Hardware ORs saturate once; "more inputs saying yes" doesn't make the output "more on".)
  • Remove the LDR entirely. The divider is now just 10 kΩ pulling the middle node up to +. What does the circuit do? (Base is always pulled high, transistor always saturated, LED always on regardless of light or button. The LDR is what gives the circuit its "automatic" character — without it, you've built a plain-vanilla First Light that happens to go through a transistor.)

For grown-ups: safety notes

  • Battery-safe end to end. The LED lane draws ~10 mA whenever the lamp is on; the override branch, when the button is held, adds ~3.6 mA through the 1 kΩ pull-up (that's (4.5 − 0.9) ÷ 1000). The divider itself drains < 0.1 mA. Peak battery total is ~14 mA at 4.5 V — a 63 mW load. Three AAs sustain that for over a week of continuous "on".
  • The 1 kΩ override resistor warms slightly in your hand after a few seconds of holding the button — 3.6 mA × 3.6 V = 13 mW. Well under its 250 mW rating; you'll feel body-temperature, not hot. If it feels OBVIOUSLY warm (above 40 °C), you likely swapped the 1 kΩ for a 220 Ω — current climbs to 16 mA and dissipation climbs to 55 mW. Still safe, but outside the design.
  • Daytime standby draws microamps. Leave the project set up on a windowsill for weeks; the batteries will outlive the attention span of any kid including the one who built it.
  • Transistor pins: flat face toward you, legs E-B-C left to right. Base ties to the 1 kΩ base resistor (middle → base), NOT the 1 kΩ override. Those are two different resistors doing two different jobs on two different sides of the middle node — don't confuse them. Scramble transistor pins and the circuit either sits on all the time (base/emitter swapped) or never fires (base/collector swapped).
  • LED polarity: long leg toward the 220 Ω, short leg toward the collector. Reversed = dark forever.
  • The push button is a momentary input: press and hold for the override. Letting go returns the circuit to automatic mode. Don't substitute a slide switch unless you want a latched override that stays on until someone remembers it.
  • Never wire this to mains. Battery-only.

Checked against

Keep building