Level 3 · Sense · project 6 of 12 · 30 min · ●●●○○

Reading Light

The Automatic Night Light with a knob on top — turn it to dial in how dark the room has to get before the lamp fires. Your first tunable threshold.

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

you'll learn: Voltage dividers · Transistor switching · 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.

  • Knob does nothing. Pot wired to its two outer legs (fixed 10 kΩ). Use the middle (wiper) + ONE outer leg.
  • LED never turns on, no matter the knob. 2N2222 pins E-B-C (flat face toward you). Then confirm the LDR is on the BOTTOM of the divider (same as Automatic Night Light).
  • LED always on, no matter the knob. Divider is flipped. LDR on the bottom, pot in place of the top 10 kΩ.
  • Knob triggers at both ends. Room too dark for the design. Point a lamp at the LDR — a good knob range should span dusk to full night.
  • LED very dim when on. Wrong resistor in the LED lane. 220 Ω = red-red-brown; anything bigger dims it.

What you're building

Sit down with a book at dusk. Somewhere between "still bright" and "too dark to read", your eyes give up. But whose dusk? Yours is different from your parents'. That's why the Automatic Night Light you built last has a small problem — it triggers at one fixed level, and that level was baked into the resistor you soldered in.

This project fixes that. Swap the fixed 10 kΩ resistor on top of the sensing divider for the 10 kΩ potentiometer you first met in Dial-a-Brightness and Whisper Alarm. Now the trigger point is adjustable. Turn the knob one way: the lamp waits for proper darkness. Turn it the other way: the lamp fires at the first hint of shadow.

You still have one hand on the electronics. Now you have one hand on the tuning too.

The big idea: a knob on the threshold

The sensing half is still the divider trick from Automatic Night Light. But look what happens when you make the top of the divider variable instead of fixed:

V_middle = 4.5 V × R_LDR ÷ (R_pot + R_LDR)

  • Knob all the way up (pot ≈ 10 kΩ): identical to Automatic Night Light. Bright room, LDR ≈ 1 kΩ → V_mid = 4.5 × 1 ÷ 11 ≈ 0.41 V (below the 0.7 V wake-up line). Lamp off. Dark room, LDR ≈ 100 kΩ → V_mid tries for 4.5 × 100 ÷ 110 = 4.1 V (base clamps at ~0.7 V). Lamp on. This is the "chill" setting.
  • Knob halfway (pot ≈ 5 kΩ): now bright room V_mid = 4.5 × 1 ÷ 6 = 0.75 V. That's right at the wake-up line — the lamp sits on the edge in daylight and lights on the first hint of dimness. This is the "reading" setting.
  • Knob all the way down (pot ≈ 1 kΩ): bright room V_mid = 4.5 × 1 ÷ 2 = 2.25 V — way past the wake-up line. The lamp is always on, regardless of light. This is the "always-on" setting — useful for a moment to prove the wiring works, not useful as a lamp.

Notice the pattern: a bigger top resistor makes the lamp less sensitive (waits for more darkness). A smaller top resistor makes it more sensitive (fires easily). The pot lets you dial that in without soldering a different resistor every time.

Do the "sensitivity dial" math

You can turn any of those pot positions into an actual darkness threshold — what LDR value crosses the 0.7 V line — by rearranging the divider equation:

R_LDR at trigger = R_pot × 0.7 ÷ (4.5 − 0.7) = R_pot × 0.184

  • Pot at 10 kΩ: triggers when LDR climbs past 1.84 kΩ. That happens in fairly dim indoor light — hand cupped over the sensor, or evening room with no lamps.
  • Pot at 5 kΩ: triggers when LDR passes 0.92 kΩ. Which is right around normal room-lit resistance — the lamp is basically always on unless the room is directly sunlit.
  • Pot at 2 kΩ: triggers at 370 Ω — brighter than the LDR can usually reach at room light. Lamp fires almost immediately.

The 0.184 constant (technically V_be / (V_battery − V_be)) is a useful shortcut. Any bright-triggered / dark-triggered divider with one variable side has the same shape.

Do the output-side math (unchanged)

The output lane is the same LED + 220 Ω that lived in Automatic Night Light. When the transistor saturates:

  • V left for the resistor: 4.5 − 2.0 (red LED) − 0.2 (V_CE(sat)) = 2.3 V
  • I_LED = 2.3 ÷ 220 ≈ 10.5 mA

Bright reading light, comfortably inside the LED's happy 8–15 mA window. Nothing about the LED changes when you turn the pot. The knob tells the transistor when to switch on, not how brightly. The transistor keeps the sensing half separate from the output half.

Build it

If your Automatic Night Light is still on the breadboard, this is a one-part swap: pull the 10 kΩ resistor at the top of the divider and replace it with the potentiometer. Wire the pot's middle leg (the wiper) to the sensing middle row; wire one outer leg to the + rail. (The third leg can stay unconnected — you're using the pot as a variable resistor, not a full divider.)

Fresh build:

  1. Power rails: battery + to a top row on the breadboard, battery to a bottom row.
  2. The sensitivity knob (top of divider): + rail → pot's middle leg → sensing middle row. + rail → pot's outer leg. Leave the third leg open.
  3. The sensor (bottom of divider): sensing middle row → LDR → rail.
  4. The base link: sensing middle row1 kΩ → transistor Base (middle leg, flat face toward you).
  5. The output half: + rail → 220 Ω → LED long leg → transistor Collector (right leg). Emitter (left leg) → rail.
  6. Tune it: start with the knob all the way up (max R). Turn the room lights off. LED should be on. Turn the room lights on. LED should be off. If it never turns off, turn the knob higher; if it never turns on even in the dark, turn it lower. You are tuning a sensor threshold — a real skill you'll use with every analog sensor for the rest of your electronics life.

Where "tunable threshold" leads

Every real sensor circuit has a sensitivity knob somewhere. Smoke detectors have a factory-set threshold you never see. Thermostats have a dial on the front. Automatic streetlights have a small pot inside the case that the technician sets during install. You just built the same idea by hand.

At Level 6 you'll meet a chip called the comparator whose whole job is to compare an analog voltage against an adjustable reference and snap crisply between off and on. You've built a soft version here (the transistor's fade-in region). At Level 7 you'll replace the pot with code — if lightSensor < threshold: light.on() — and threshold becomes a variable you can change in software. It is the same threshold idea in bigger circuits.

🧠 Your challenge

No single right answer. That's the point.

  • Sensitivity math. Using the 0.184 shortcut above, work out what LDR value triggers the lamp when the pot is at 3 kΩ. Then check on the physical build: turn the pot to about a third of the way up (3 kΩ is 30% of the pot's 10 kΩ range) and see where the lamp fires. Does the math match? (If not, either the pot fraction isn't what you thought, or the LDR is dirtier than the "1 kΩ bright / 100 kΩ dark" table suggests. Both are useful learning.)
  • Reading vs snooze. Set the pot so the lamp fires when the room is at a reading-lamp level of dimness. Now shine a phone torch on the LDR. Does the lamp go off? Time how many seconds the transition takes between "on" and "off". (You've just measured the analog fade-out region — the mushy zone the Level 6 comparator chip will crisp up later.)
  • Two knobs, one sensor. Add the 1 kΩ resistor in series with the bottom of the divider (between LDR and rail). Now both ends of the divider have some structure. Redo the bright-room math: with pot at 10 kΩ, LDR at 1 kΩ, 1 kΩ in series with the LDR, what's V_mid? Is the lamp still safely off in daylight? (You're making the alarm less jumpy in a different way than just turning the pot up. Both approaches are used in real designs.)
  • Flip the divider. Move the pot to the bottom of the divider (in place of the LDR) and move the LDR to the top (in place of the pot). Predict what the lamp now does before you power it up. (You've built an adjustable version of the Sunrise Alarm — bright-triggered instead of dark-triggered.)

For grown-ups: safety notes

  • Battery-safe throughout — even with the lamp firing at ~10 mA and the divider sipping under 1 mA, total battery current tops out around 12 mA. Fresh AAs last many days of intermittent night use.
  • The pot's third leg matters. If you connect all three legs to live rails, the pot becomes a full divider and behaves differently — you may see the lamp always on, or always off, no matter which way you turn it. Leave the third leg unconnected and this project works. (A full pot divider is a real technique; it's the "voltage-out" mode you'll meet with the Arduino at Level 7.)
  • If the transistor is warm to the touch, disconnect the battery and re-check the E-B-C leg order (flat face toward you). A backwards transistor is the #1 suspect, still.
  • The LDR is direction-independent (it's not polarized) but its surface picks up fingerprints — wipe it gently with a soft cloth if it seems less sensitive than it should be. Dust and grease raise its bright-room resistance and make the whole circuit more jumpy.
  • Don't seal this in a shoebox and leave it running for weeks. It's electrically safe to do so, but the LDR needs a clear view of the room's light and the batteries do their best work with some airflow. A shelf or windowsill is fine; the back of a drawer is not.

Checked against

Keep building