Lesson 4 of 15

Voltage Divider

The Voltage Divider

A voltage divider is two series resistors used to produce a fraction of the supply voltage:

    +Vin
     |
    [R1]
     |
     +---- Vout
     |
    [R2]
     |
    GND

The output voltage:

Vout = Vin · R2 / (R1 + R2)

Derivation

The same current flows through R1 and R2 (series circuit):

I = Vin / (R1 + R2)
Vout = I · R2 = Vin · R2 / (R1 + R2)

Intuition

The output is a ratio: Vout/Vin = R2/(R1+R2). Only the ratio of resistors matters, not their absolute values.

  • R1 = R2 → Vout = Vin/2 (splits evenly)
  • R2 >> R1 → Vout ≈ Vin (almost no drop on R1)
  • R2 << R1 → Vout ≈ 0 (almost all drop on R1)

Applications

  • Setting bias voltages in amplifiers
  • Scaling sensor outputs to ADC range
  • Level shifting (e.g., 5V → 3.3V logic)

Warning

A voltage divider is only accurate when the load resistance is much larger than R2. A low-resistance load "steals" current and pulls Vout down.

Examples

VinR1R2Vout
12V10Ω10Ω6V
5V2V
9V3V
10V7V

Your Task

Implement double voltage_divider(double vin, double r1, double r2) that returns Vout.

TCC compiler loading...
Loading...
Click "Run" to execute your code.