Learning Goals 5 min
By the end of this lesson you will be able to:
- Write down the voltage-divider formula —
Vout = Vin × R2 / (R1 + R2)— and explain what each symbol means in plain English. - Calculate the voltage at the junction (and the predicted
analogReadvalue) for any combination ofVinand two resistor values, without uploading. - Pick a sensible fixed resistor for a given sensor by aiming for the divider to sit near the middle of the 0–5 V range at "normal" conditions — the rule that makes 10 kΩ such a common default for hobby LDRs.
Warm-Up 10 min
You wired a voltage divider in L01-36 — LDR on top, 10 kΩ on the bottom, A0 in the middle — and trusted the readings. Today you open the hood and find out why the numbers come out the way they do. The same maths will let you pick the right "partner resistor" for any future sensor whose resistance changes — temperature probes, soil moisture, force, even your own fingertip's resistance.
Quick-fire puzzle
Imagine two identical 1 kΩ resistors connected end-to-end, with 5 V across the whole pair and your voltmeter touching the middle.
- What voltage do you think the meter reads at the middle? Why?
- Now replace the top resistor with a 9 kΩ. (Bottom is still 1 kΩ.) Does the middle voltage rise or fall? Roughly to what?
- What would the middle read if the top resistor were replaced with a wire (zero ohms)?
Reveal the answer
- 2.5 V — exactly half. The two equal resistors split the 5 V evenly. This is the most intuitive case of a voltage divider; everything else is a generalisation of it.
- The middle drops to about 0.5 V. The top resistor is now 9× the size of the bottom one, so 9/10 of the 5 V drops across it, leaving only 1/10 (0.5 V) for the bottom resistor — and the junction sits at the top of the bottom resistor, which is 0.5 V above GND.
- 5 V exactly. A wire has no resistance, so it drops no voltage. All 5 V appears across the bottom resistor; the junction sits at the top of it, which is 5 V above GND.
The relationship has a name and a single formula. Today's lesson is that formula, what it predicts, and why ignoring it leads to "the sensor reading just doesn't change much" bugs.
New Concept — the divider formula 20 min
The setup — two resistors, one junction
Every voltage divider in this course has the same shape: a top resistor (R1) and a bottom resistor (R2) in series, with the supply voltage (Vin, usually 5 V on a Uno) across the pair and GND at the bottom. The output voltage (Vout) appears at the junction between them — exactly the point you tap with the A0 wire.
Vout is the voltage at the junction, measured against GND — exactly what your A0 pin sees. In L01-36's circuit, R1 was the LDR (variable) and R2 was the 10 kΩ (fixed). Today the formula tells us what voltage to expect for any values of R1 and R2.The formula
Here it is, the one equation you need:
Vout = Vin × R2 / (R1 + R2)
In words: the output voltage is the input voltage times R2 over the sum of both resistors. R2 is in the numerator because Vout is measured across R2 — the more of the total resistance R2 represents, the more of the total voltage drops across it.
Three sanity-check cases
Plug in extreme values and check the formula matches your intuition. These three checks confirm the formula is correct without any algebra:
- R1 = R2:
Vout = 5 × R / (R + R) = 5 × 1/2 = 2.5 V. ✓ Matches the warm-up's "two equal resistors = halve the voltage". - R1 = 0 (wire):
Vout = 5 × R2 / (0 + R2) = 5 V. ✓ The full supply appears at the junction because R1 drops nothing. - R2 = 0 (wire to GND):
Vout = 5 × 0 / (R1 + 0) = 0 V. ✓ The junction is wired to GND through R2, so it sits at 0 V.
From Vout to analogRead
The Arduino's ADC turns 0–5 V into the integer 0–1023, linearly. So once you have Vout, you can predict the analogRead value:
analogRead value ≈ Vout × 1023 / 5
Or, combined with the divider formula, in one step:
analogRead value ≈ 1023 × R2 / (R1 + R2)
The 1023 replaces the 5 V because the maximum reading replaces the maximum voltage. Same shape, different units.
Why the partner resistor matters so much
For a varying-resistance sensor (LDR, thermistor, etc.) the goal is to pick the fixed resistor so the junction voltage swings across as much of the 0–5 V range as possible across the sensor's working range. If the fixed resistor is way too small or way too big, one of the two will always "win" and the junction will barely move.
- R2 way smaller than R1: the junction sits near 0 V at almost every R1 value. Tiny readings, tiny swings — you lose all the sensor's range to noise.
- R2 way bigger than R1: the junction sits near 5 V at almost every R1 value. Huge readings, tiny swings — same problem at the other end.
- R2 ≈ the "middle" value of R1: the junction swings fully as R1 changes — the sensor's range is mapped onto the ADC's range. Maximum sensitivity, easiest to set thresholds.
For a hobby LDR ranging from about 1 kΩ (bright) to about 100 kΩ (dark), a 10 kΩ fixed resistor sits in the geometric middle. That's why 10 kΩ is the universal default — it's not magic, it's just well-matched to the part.
Why it matters
Every analog sensor in the rest of this syllabus — thermistors, force-sensitive resistors, soil-moisture probes, even some MEMS gas sensors — is a "resistor that changes with something". They all need a partner resistor and they all give a junction voltage you read with analogRead. Master the formula once and you can wire and predict any of them. Skip it and you'll be re-soldering resistors all year trying to figure out why "the readings just don't change enough".
Worked Example — predict, then verify 20 min
Same L01-36 wiring: LDR on top (R1, variable), partner resistor on bottom (R2, fixed), junction to A0. The plan: calculate the expected reading for several scenarios on paper, then upload a tiny print sketch and check whether the real chip agrees.
Step 1 — The print-only sketch
You'll keep uploading this exact sketch — only the resistors on the breadboard change.
// LDR + partner — print live ADC reading
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println(analogRead(A0));
delay(200);
}Step 2 — Predict three readings on paper
Take a typical kit LDR with these approximate values:
- Bright room (lamp shining directly): RLDR ≈ 2 kΩ
- Normal room light: RLDR ≈ 10 kΩ
- Covered (fingertip pressed on top): RLDR ≈ 100 kΩ
With R2 = 10 kΩ (today's partner), what does the formula predict?
Scenario A — bright room (RLDR = 2 kΩ, R2 = 10 kΩ)
- Given: Vin = 5 V, R1 = 2 kΩ, R2 = 10 kΩ
- Find:
analogReadvalue - Formula:
1023 × R2 / (R1 + R2) - Working:
1023 × 10 / (2 + 10) = 1023 × 10 / 12 = 1023 × 0.833 =~852
Scenario B — normal room (RLDR = 10 kΩ, R2 = 10 kΩ)
- Given: Vin = 5 V, R1 = 10 kΩ, R2 = 10 kΩ
- Find:
analogReadvalue - Formula:
1023 × R2 / (R1 + R2) - Working:
1023 × 10 / (10 + 10) = 1023 × 0.5 =~512
Scenario C — covered (RLDR = 100 kΩ, R2 = 10 kΩ)
- Given: Vin = 5 V, R1 = 100 kΩ, R2 = 10 kΩ
- Find:
analogReadvalue - Formula:
1023 × R2 / (R1 + R2) - Working:
1023 × 10 / (100 + 10) = 1023 × 10 / 110 = 1023 × 0.091 =~93
So with a 10 kΩ partner, your readings should swing roughly from ~90 (covered) through ~510 (normal) up to ~850 (bright) — using about 75% of the ADC's full range. That's healthy.
Step 3 — Upload and confirm
- Build the L01-36 wiring with a 10 kΩ partner. Upload the print sketch.
- Open the Monitor. Note the reading at normal room light — should be somewhere near 500.
- Cover the LDR with your fingertip — reading should drop toward 100.
- Shine your phone torch directly at it — reading should climb toward 900.
- Your real numbers will differ from the predictions (every LDR is slightly different and your room isn't exactly "normal"), but they should be in the same ballpark.
Step 4 — Now break it deliberately — swap to 1 kΩ
Replace the 10 kΩ with a 1 kΩ resistor (the same colour-banded part used as series resistance for LEDs in earlier lessons would also work — anything 220 Ω to 1 kΩ). Recalculate before testing:
Same LDR, partner R2 = 1 kΩ
- Bright (RLDR = 2 kΩ):
1023 × 1 / (2 + 1) =~341 - Normal (RLDR = 10 kΩ):
1023 × 1 / (10 + 1) =~93 - Covered (RLDR = 100 kΩ):
1023 × 1 / (100 + 1) =~10
Whole range squeezed into roughly 10–341 — only a third of the ADC. Upload and verify: cover the LDR and the reading barely changes from "covered" to "normal" — you've lost most of the sensor's resolution. The fixed resistor is so small that the LDR dominates at every brightness, and the junction stays near GND.
Step 5 — Try the other extreme — 100 kΩ partner
Same LDR, partner R2 = 100 kΩ
- Bright (RLDR = 2 kΩ):
1023 × 100 / (2 + 100) =~1003 - Normal (RLDR = 10 kΩ):
1023 × 100 / (10 + 100) =~930 - Covered (RLDR = 100 kΩ):
1023 × 100 / (100 + 100) =~512
Now the readings are squeezed into ~510–1000: the whole sensor range is pinned to the top of the ADC and "bright" vs "normal" become almost indistinguishable. R2 too big this time.
The takeaway
10 kΩ swings the reading across most of 0–1023. 1 kΩ pins it to the bottom; 100 kΩ pins it to the top. The "best" R2 is approximately the geometric mean of the sensor's minimum and maximum resistance — for a 2 kΩ to 100 kΩ swing, that's √(2 × 100) ≈ 14 kΩ. The nearest standard part is 10 kΩ or 15 kΩ; both will work well. This is the rule behind every "use a 10 k" instruction in every Arduino tutorial.
Try It Yourself — three calculations and a swap 15 min
Goal: Predict the analogRead value for each scenario without uploading. Do the arithmetic in your notebook, show working.
- (a) Vin = 5 V, R1 = 4.7 kΩ, R2 = 4.7 kΩ. Find
analogRead. Working: ____ - (b) Vin = 5 V, R1 = 1 kΩ, R2 = 9 kΩ. Find
analogRead. Working: ____ - (c) Vin = 5 V, R1 = 100 kΩ, R2 = 10 kΩ. Find
analogRead. Working: ____ - (d) Vin = 5 V, R1 = 10 Ω, R2 = 10 Ω. Find
analogRead. (Does it surprise you?) ____
Questions:
- Look at (a) and (d): both have R1 = R2. Both should give the same
analogReadregardless of the actual ohms value. Why? ____ - Of (a) through (d), which scenario uses the divider in its middle range (sitting close to 512)? ____
- Why didn't I include a case where R1 = R2 = 0? ____ (Hint: a 5 V supply directly to GND through zero resistance is a short circuit.)
Goal: Inverse problem — given a target analogRead and a known R1, find R2.
A thermistor (a temperature-sensing resistor) reads about 33 kΩ at room temperature (20 °C). You want the junction to sit at about 2.5 V at room temperature (so the ADC reads about 512) — that way warming the thermistor sends the reading one way and cooling it sends the reading the other way, with maximum sensitivity in both directions.
- Given: Vin = 5 V, Vout = 2.5 V, R1 = 33 kΩ
- Find: R2
- Hint: rearrange the formula.
Vout × (R1 + R2) = Vin × R2→ solve for R2. - Working: ____
- Pick the closest standard E12 value (10 k, 15 k, 22 k, 33 k, 47 k, 68 k…). Standard pick: ____
Questions:
- Why does the answer turn out to be "the same as R1"? ____ (Hint: when Vout is half of Vin, R2 must equal R1.)
- If you used a thermistor that's 33 kΩ at room temperature but drops to 10 kΩ when warmed, what
analogReadvalue would you see at the warmed reading with R2 = 33 kΩ? ____ - Why is "sit near 2.5 V at the most common reading" a good design goal for an analog sensor? ____
Goal: Physically swap your partner resistor. Replace the 10 kΩ in your L01-36 circuit with a 4.7 kΩ (a very common kit part — yellow-violet-red). Predict, then test.
- Predict the
analogReadat three brightnesses (covered, normal, torch-on), using your L01-36 LDR's approximate values from the worked example.- Covered: ____
- Normal: ____
- Torch: ____
- Build it. Upload the print sketch. Note the real readings.
- Covered: ____
- Normal: ____
- Torch: ____
- How close were your predictions? If they're off, in which direction? Is the actual LDR resistance bigger or smaller than your assumed values? ____
Questions:
- With 4.7 kΩ instead of 10 kΩ, does the sensor swing more or less of the ADC range than with 10 kΩ? ____
- If you were designing a brightness sensor for a phone, would you prefer "swings most of the range" or "perfectly mid-scale at normal indoor light"? Argue for one. ____
- The E12 standard resistors include 6.8 kΩ. Would 6.8 kΩ be a better or worse choice than 4.7 kΩ for your LDR? ____ (Hint: closer to the geometric mean = better.)
Mini-Challenge — design from scratch 10 min
"Choose the right resistor for a brand-new sensor"
You're given a hypothetical force-sensitive resistor (FSR) with these specs from its datasheet:
- No force applied: resistance is essentially infinite (open circuit).
- Light press (a fingertip resting): about 30 kΩ.
- Hard press (a thumb pushing): about 1 kΩ.
Your task: design a voltage divider for it.
- Pick a partner resistor (R2) value from the E12 series (1 k, 2.2 k, 3.3 k, 4.7 k, 6.8 k, 10 k, 15 k, 22 k, 33 k, 47 k, 68 k, 100 k) to maximise sensitivity in the press range (1 kΩ to 30 kΩ).
- Calculate the
analogReadvalues you'd expect at no-force, light-press, and hard-press. - Write down a Serial-Monitor-style table of your predictions.
- Explain in one sentence why you chose that R2 — what would have gone wrong with R2 = 1 kΩ, or with R2 = 100 kΩ?
It works if:
- Your R2 choice is a real E12 value.
- Your "light press" and "hard press" predictions are at least 200 ADC units apart (so you can reliably tell them apart in code).
- You can defend your R2 against both extremes (too small / too big) in one sentence each.
Reveal one valid design
Choice: R2 = 4.7 kΩ. Geometric mean of 1 kΩ and 30 kΩ is √30 ≈ 5.5 kΩ; the closest E12 value is 4.7 kΩ (or 6.8 kΩ; both would work).
Predictions:
No force: 1023 × 4.7 / (∞ + 4.7) = ~0 (FSR open → junction at GND)
Light press: 1023 × 4.7 / (30 + 4.7) = ~139
Hard press: 1023 × 4.7 / (1 + 4.7) = ~843Defence: With R2 = 1 kΩ, both press values would be in the bottom quarter of the ADC (~33 and ~512), hard to set thresholds. With R2 = 100 kΩ, both press values would be near the top (~970 and ~999), almost indistinguishable. The middle choice gives a 700-unit swing across the working range — easy to discriminate "light" vs "hard" by code.
The same reasoning applies to every analog sensor you'll wire from here on: list the working range of the sensor's resistance, take the geometric mean, round to the nearest E12 value. Five minutes of arithmetic saves hours of "why doesn't my sensor work" debugging later.
Recap 5 min
Every analog sensor in this course follows the same circuit: a variable resistor on top (R1), a fixed partner resistor on bottom (R2), the supply (Vin) across the pair, the junction (Vout) tapped by the analog pin. The voltage divider formula Vout = Vin × R2 / (R1 + R2) tells you what voltage to expect; multiplying through by 1023/5 tells you what analogRead will return. Picking R2 around the geometric mean of the sensor's resistance range gives the biggest swing in the ADC and the most sensitive readings. 10 kΩ is the universal default because most hobby sensors are roughly in its working range — but now you know why, and how to pick something better when the default doesn't fit.
- Voltage divider
- Two resistors in series between Vin and GND, with the analog pin tapping the junction. The shape of every variable-resistor sensor circuit in this course.
- R1 (top resistor)
- The resistor connected between Vin and the junction. In sensor circuits, this is usually the variable part (the LDR, thermistor, FSR, etc.).
- R2 (bottom resistor)
- The resistor connected between the junction and GND. Usually the fixed "partner" — picked by the designer to match the sensor's working range.
- Vout (junction voltage)
- The voltage at the tap point, measured against GND.
Vout = Vin × R2 / (R1 + R2). - Geometric mean rule
- For a sensor whose resistance ranges from Rmin to Rmax, the best fixed partner resistor is approximately √(Rmin × Rmax). This places the junction near 2.5 V at the middle of the sensor's range, swinging across most of the ADC.
- E12 standard values
- The 12 resistor values per decade you can actually buy: 1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2 — multiplied by 1, 10, 100, 1 k, etc. The most-stocked subset of these in hobby kits is 1 k, 2.2 k, 4.7 k, 10 k, 22 k, 47 k, 100 k.
- ADC input impedance
- The (very large) effective resistance the Arduino's analog pin presents to the junction. For R values under 100 kΩ, you can ignore it; above that, the ADC starts to pull current and skew readings.
Homework 5 min
Five divider calculations on paper. No Arduino needed. For each row of the table, calculate Vout and the predicted analogRead. Show working for at least three of the five.
| # | Vin | R1 | R2 | Vout | analogRead |
|---|---|---|---|---|---|
| 1 | 5 V | 10 kΩ | 10 kΩ | ____ | ____ |
| 2 | 5 V | 22 kΩ | 10 kΩ | ____ | ____ |
| 3 | 5 V | 4.7 kΩ | 4.7 kΩ | ____ | ____ |
| 4 | 5 V | 1 kΩ | 10 kΩ | ____ | ____ |
| 5 | 5 V | 100 kΩ | 1 kΩ | ____ | ____ |
Also: a design reflection on paper.
- Of rows 1–5 above, which ones put Vout in the middle of the 0–5 V range (between 2 V and 3 V)? Which put it near 0 V? Which near 5 V? ____
- A real soil-moisture sensor reads about 20 kΩ when soil is dry and 1 kΩ when soil is wet. What single E12 R2 would you pick to make the readings span most of the ADC? Justify in two sentences. ____
- You bought an LED-strip controller that has a 100 kΩ "ambient light" input pin labelled "0–5 V". You want to drive it from your existing LDR + 10 kΩ divider. Does that work as-is? ____ (Hint: the controller's input impedance might be lower than the ADC's; check the L01-38 watch-out about ADC impedance.)
- Why is the divider formula symmetric in shape but not in meaning — i.e. why does the choice of "which resistor is R1 and which is R2" matter? ____
Bring back next class:
- Your completed five-row table on a notebook page, with working shown for three of them.
- Your four written reflection answers.
- No
.inofile this time — today's homework is pure paper-and-pencil thinking.
Heads up for next class: L01-39 "Tilt Switches" introduces your first motion-aware sensor — a tiny tube with a metal ball inside that closes a circuit when it tips. Not a resistor sensor, no divider needed — just a digital read with INPUT_PULLUP. Compared to today, it'll feel like a holiday.