How it works
Two resistors in series across a supply split the voltage in proportion to their values. The output is taken across R2, the resistor connected to ground.
This assumes nothing else draws significant current from the output. If the load's input impedance is not at least ten times R2, the real output will be lower than calculated.
Vout = Vin × R2 / (R1 + R2)
R2 = R1 × Vout / (Vin − Vout)Worked example
To read a 12 V battery with a 3.3 V ADC, R1 = 10 kΩ and R2 = 4.7 kΩ give 12 × 4.7 / 14.7 = 3.84 V. That's too high for 3.3 V, so try R2 = 3.3 kΩ: 12 × 3.3 / 13.3 = 2.98 V, with margin for a fully charged battery.