# How to solve for current given resistor value for LED circuit?

So I have the following LED circuit:

I know how to find the forward voltage and current from the datasheet of the LED and how to then solve for the appropriate value of $R$.

However, what I really want to do is fix the resistor value at $R=100$ (I'm just picking a resistor value that exists in a kit I have) and solve for $I_F$:

The only way I can currently think of to solve this is:

$$V_F+V_R=V_{CC}-V_{OL}$$ $$V_F+I_FR=V_{CC}-V_{OL}$$ $$V_F+100I_F=4.3$$

I found $(V_F,I_F)=\{(2.3, 20), (2.8,15)\}$ to be 2 arbitrary solutions to the equation. Then I graphed a line on the VI plot to determine all possible solutions to the equation. Finally I found the intersection of the line and the VI plot to determine what was the true solution to the equation is.

From this it looks like $V_F=2.1$ and $I_F=22$.

However, this was a lot of work for such a basic circuit. Is there an easier way to solve for or at least nicely estimate what $I_F$ would be given $R$? The value of the current matters a lot to me because I need to make sure I don't fry my microcontroller!

Is there an easier way to solve for or at least nicely estimate what $I_F$ ... because I need to make sure I don't fry my microcontroller!

Two easy solutions:

• Choose a target current that's well below the limits of the micro or LED, like 5 mA instead of 20 mA, then just assume $V_F$ is close to its nominal value (say, 2.2 V in this example). If the LED doesn't have to be visible in very bright light, 5 mA should be adequate (or you should be able to find a different LED that is adequately visible with 5 mA)

or

• Use a transistor buffer with much more than 20 mA capability to eliminate risk to the micro.

Before you try to calculate the diode current any more precisely, you should consider that the diode forward voltage is likely to vary by 100 mV or more as its temperature changes.

• Transistor buffer seems like too much extra IC, tryna keep the circuit small, so I'm hoping to hit a current value that the MCU can handle by itself. I don't quite understand your first solution though, are you saying basically just solve for $R$ given a target $I_F$ like normal? What do I do if the particular resistor value I need isn't in my kit? Dec 26, 2017 at 23:25
• @rcplusplus "I'm hoping to hit a current value that the MCU can handle by itself" Please don't, that's not what an MCU is supposed to do. MCU is for precision calculation and signalling power switches. Use at least a driver like an ULN200x, but a transistor should be enough in this case.
– Mast
Dec 26, 2017 at 23:52
• @Mast Well an intermediary goal is to power a common anode seven segment (which I'd model as 7 LEDs in parallel with their anodes tied together). To source the current I was gonna use a pmos since the source needs to handle $7*I_F$. However for the 7 cathodes, I was thinking each one could just be directly controlled by the MCU. Would a better idea be to use a current sinking chip? Dec 27, 2017 at 0:24
• @Mast also wouldn't relying on a separate chip/component just to turn on an LED be kinda overkill? Especially if the MCU can handle it perfectly well on it's own? Dec 27, 2017 at 0:30
• @rcplusplus see the last sentence of Spehro's answer: Just pick a resistor that gives a bright enough LED with plenty of margin to your max current limits. Dec 27, 2017 at 1:27

You're on the right track. You can simply overlay the load-line for your chosen resistor value onto the LED IV curve. Here's one I did:

Figure 1. Various resistor and LED load-lines for a 5 V supply. The intersection of a resistance and IV curve gives the operating point. Source: LEDnique.com.

I'm still working on the curves which are somewhat off. (The blue and white, for example, should be much closer.)

There are some worked examples on the linked page.

• You seem to have green and yellow out of order. Dec 26, 2017 at 19:00
• Is anyone taking into account the safe current/temperature levels of a given LED type? There are LED's that max out at 2 mA, 20 mA, and 200 mA. Though the LED forward voltages may be close, the operating current can vary a great deal.
– user105652
Dec 26, 2017 at 19:57

You are wasting your time, assuming this is a simple visual indicator, for several reasons.

The LED forward voltage vs. current curve is not guaranteed, only usually a fixed point, or two. It varies from unit-to-unit and with temperature. You might want to change manufacturers in the future and the chemistry or internal resistance might be a bit different.

The visual brightness does not change all that much with current due to logarithmic eye response- a good LED at 5mA can be almost too bright, and a old school one at 20mA can be meh.

GPIO minimum drop is usually not specified at all, at any currents, just the maximum.

You should be nowhere near the current level that would "fry" your GPIO. Otherwise you are likely to run into reliability issues.

While there is a geek appeal in fitting a curve to the LED and to the GPIO output IV curves and hitting some arbitrary current target within a fraction of a percent, it's not really that useful a trick. If it requires that much effort it will likely be too variable.

Just pick a value that will give enough brightness and has plenty of margin.

• I guess I might be the geek! I'm not really. I address the spread in LED $V_f$ in my answer to Circuit with 10 LEDs. I agree completely with your answer, as usual. Dec 26, 2017 at 21:16
• So the thought process really go like this: To get 15mA of current, I need a 150Ω resistor. From my kit I can pick either a 100Ω or a 220Ω resistor. I'd rather err on the side of too little current so I just go for the 220Ω resistor. Is that what you meant? Dec 26, 2017 at 23:22
• @rcplusplus Pretty much, though I don't think anyone needs 15mA these days for an indicator. Are you sure 5mA isn't bright enough? Dec 26, 2017 at 23:59
• @SpehroPefhany It could be, tbh I'm really just guessing here haha. My end goal is to power a 7 segment display (which I'm just modeling as 7 LEDs in parallel). I assumed you need ~10-15mA to make an LED glow a nice value but I can try a small current value. This is all for now just theoretical value calculation and I was a little more interested in the process anyhow! Dec 27, 2017 at 0:20