LED series resistor
An LED's current climbs steeply once its voltage passes the forward voltage, so it can't be connected straight to a battery: the resistor takes up the rest of the supply voltage and sets the current. The higher the supply, the more of the power the resistor turns into heat.
The formulas
- Resistor: round the loop the voltages add up (Kirchhoff's voltage law), Vs = I R + Vf, so R = (Vs − Vf) ÷ I, with Vs the supply, Vf the LED's forward voltage and I the current you want.
- Power: the resistor takes (Vs − Vf) × I, the LED Vf × I, and the supply gives Vs × I. The LED's share is Vf ÷ Vs.
- With a different resistor R′ fitted, the current is about (Vs − Vf) ÷ R′. Rounding the resistor up to the next value you have lowers the current slightly, which is the safe direction.
Take the forward voltage and the current from your LED's datasheet: they differ by colour, type and maker, and the current must stay within the datasheet's maximum. The model treats the forward voltage as fixed; a real LED's voltage rises a little with current, so the true current comes out slightly lower. Choose a resistor whose power rating is comfortably above the power shown. If the supply is at or below the forward voltage, no resistor works and the LED stays dark. Tested: the resistor value is checked by solving the loop numerically with an exponential diode model that passes the chosen current at the forward voltage, and the powers balance (packages/mechanics/test/science.test.ts).
Example
With supply voltage 9 V, LED forward voltage 2 V, LED current 20 mA: series resistor (Vs − Vf) ÷ I: 350 Ω; power in the resistor: 140 mW; power in the LED: 40 mW; share of the power used by the LED: 22.2% of the supply power. Open this setup, then change one thing at a time.
Related: Voltage divider · RC circuit · RL circuit