Two formulas cover most beginner wiring: Ohm’s law for an LED resistor, and the divider rule for scaling a voltage down. Both are below.
LED series resistor
Voltage divider
Choose the next standard resistor value up, and check the LED current is within its rating. A divider is for signals only, not for powering things.
How it is calculated
LED resistor = (supply voltage − LED forward voltage) ÷ current. The divider output = input voltage × R2 ÷ (R1 + R2), where R2 is the resistor to ground.
A worked example
A red LED drops about 2.0 V and you want 10 mA from a 5 V pin: (5 − 2.0) ÷ 0.010 = 300 ohm, so use 330 ohm. To read a 5 V signal on a 3.3 V ESP32 pin with R1 = 10 kohm and R2 = 20 kohm: 5 × 20000 ÷ 30000 = 3.33 V.
Common mistakes
- Leaving out the resistor and burning the LED or the pin.
- Using a divider to carry current. Any load on the output changes the result.
- Assuming every LED drops 2 V. Blue and white LEDs drop about 3 V; check the datasheet.
Related
ESP32 pinout for robotics, I2C device not found, Arduino IDE setup.
Last reviewed: November 2026. The calculator runs in your browser and sends nothing anywhere. Results are ideal-case figures; add margin before you order parts.
Another worked example: a white LED
A white LED drops roughly 3.0 V and you want about 15 mA from a 5 V supply. The resistor is (5 − 3.0) ÷ 0.015 = 133 ohm. A standard value of 150 ohm is the next one up. With 150 ohm the current is 2 ÷ 150 = 13.3 mA, and the resistor dissipates 0.0133² × 150 = 0.027 W, so a quarter-watt part is more than enough.
A second divider example and the loading effect
To scale a 12 V signal to about 3.3 V, the ratio R2 ÷ (R1 + R2) must be 3.3 ÷ 12 = 0.275. Pick R2 = 10 kohm, so R1 + R2 = 36.4 kohm and R1 = 26.4 kohm. The nearest common value is 27 kohm, which gives 12 × 10 ÷ 37 = 3.24 V. The divider draws 12 ÷ 37,000 = 0.32 mA.
Now connect something to the output. If the input you feed has a resistance of only 10 kohm, it sits in parallel with R2, making it 5 kohm. The output falls to 12 × 5 ÷ 32 = 1.875 V. This is why dividers suit high-impedance inputs such as microcontroller ADC pins, and why you should keep R1 and R2 small compared with the load but large enough that the divider current is low.
Assumptions and limits
- LED forward voltage depends on colour and current. Use the datasheet value at your chosen current.
- Brightness is not linear with current, and many indicator LEDs are bright at 2 to 5 mA.
- A divider only attenuates a signal. It does not isolate, protect against over-voltage or carry power. Check the input range of the pin you feed.
Common mistakes
- Putting R1 and R2 the wrong way round. R2 is the resistor to ground.
- Rounding the LED resistor down. A lower value raises the current.