Quick tip: Calculating LED Resistor Values
From a question someone posted in Discord.
what's a safe bet on how many ohms resistors for 2-pin leds should be
![:Apu:](https://cdn.discordapp.com/emojis/859210973944610836.webp?size=44&quality=lossless)
![](https://ohmbedded.com/content/images/2023/03/image-77.png)
This is the basic circuit for an LED, right? LEDs are simply diodes. Diodes are non-linear circuit elements that have a decently high resistance until they reach their Vf or forward voltage. Once they reach their forward voltage (between 1-2V for typical LEDs you will encounter and a key piece of info to find from the datasheet) they lose nearly all resistance and you can treat the circuit as the following:
![](https://ohmbedded.com/content/images/2023/03/image-78.png)
The LED is actually just another battery with voltage Vf, but opposing the voltage V of your system.
Do some ohm's law stuff. I1 = (V-Vf)/R1.
If you want your current through the LED to be something like 5-10mA, just set I1 to 5*10^-3 and solve for R1
Another thing to keep in mind is the power through the resistor. It's a good check to P = R*I^2 to verify that the power rating for the resistor is high enough and it won't get super hot.
In practice, look at the datasheet and use this calculator: https://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-led-series-resistor
Here is a quick example with a random LED.
![](https://ohmbedded.com/content/images/2023/03/image-79.png)
Max current, If, of 30mA. I will use 5mA here.
![](https://ohmbedded.com/content/images/2023/03/image-80.png)
Typical Vf of 2.0V.
![](https://ohmbedded.com/content/images/2023/03/image-81.png)
Into the calculator, we get 260 ohms with a power use of 6.5mW. Looking up the closest resistor value, I would recommend 270 ohms.
Thanks!