Circuit fundamentals
Voltage divider
Also called: potential divider · R2/(R1+R2) · level shifting
Definition
Two resistors in series across a supply produce, at their junction, a fraction of the supply voltage set by the ratio of the resistors.
Picture it
The voltage shares out in proportion to resistance, so the bottom resistor's share is R2 out of the total. Replace one resistor with a light- or temperature-dependent one and the junction voltage becomes a sensor reading a microcontroller can measure. Loading the output with a small resistance pulls the voltage down.
The maths
V_out = V_in × R2 / (R1 + R2)
| Quantity | Unit | Symbol |
|---|---|---|
| voltage | volt | V |
| resistance | ohm | Ω |
Worked example
A 5 V sensor output must be brought down for a 3.3 V input pin. With R1 = 10 kΩ on top and R2 = 20 kΩ below, what is V_out?
- V_out = 5 × 20000 / (10000 + 20000)
- = 5 × 2/3 = 3.33 V
AnswerV_out ≈ 3.33 V.
✓ The number in this answer is recomputed from scratch by an automated test.
In Python
def divider(v_in, r1, r2):
return v_in * r2 / (r1 + r2) # brackets matter
print(round(divider(5, 10_000, 20_000), 2)) # 3.33Common misconceptions
- Misconception: A divider is not a power supply: drawing current from the output changes the ratio.
- Misconception: Writing v_in * r2 / r1 + r2 without brackets computes something completely different.