9 V supply, 2 V LED, 20 mA
(9 V − 2 V) / 20 mA gives 350 Ω. The nearest E24 resistor is 360 Ω. With that part the LED current is 19.44 mA and the resistor dissipates 136.1 mW.
The resistor drops the extra voltage so the LED current stays near the value you choose.
Typical forward voltages. Replace them with the value from the LED datasheet.
(9 V − 2 V) / 20 mA = 350 Ω
The nearest E24 resistor is 360 Ω. With that part the LED current is 19.44 mA, 2.8% from the 20 mA you entered.
Power in that E24 resistor is 136.1 mW.
Calculated the same way as the tool above.
(9 V − 2 V) / 20 mA gives 350 Ω. The nearest E24 resistor is 360 Ω. With that part the LED current is 19.44 mA and the resistor dissipates 136.1 mW.
A white LED at 3.2 V and 10 mA, on 5 V, needs 180 Ω. That resistance is already an E24 value, so the current stays at 10 mA and the resistor dissipates 18 mW.
R = (Vs − Vf) / I. Enter current in milliamps; the calculation uses amperes. Power in the resistor is (Vs − Vf) × I, which is the same as I² × R.