So I have the following LED circuit:

enter image description here

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\$:

enter image description here

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.

enter image description here

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)


  • 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.

  • \$\begingroup\$ 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? \$\endgroup\$
    – rcplusplus
    Dec 26 '17 at 23:25
  • \$\begingroup\$ @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. \$\endgroup\$
    – Mast
    Dec 26 '17 at 23:52
  • \$\begingroup\$ @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? \$\endgroup\$
    – rcplusplus
    Dec 27 '17 at 0:24
  • \$\begingroup\$ @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? \$\endgroup\$
    – rcplusplus
    Dec 27 '17 at 0:30
  • \$\begingroup\$ @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. \$\endgroup\$
    – The Photon
    Dec 27 '17 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:

enter image description here

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.

  • 1
    \$\begingroup\$ You seem to have green and yellow out of order. \$\endgroup\$ Dec 26 '17 at 19:00
  • \$\begingroup\$ 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. \$\endgroup\$
    – user105652
    Dec 26 '17 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.

  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Transistor
    Dec 26 '17 at 21:16
  • \$\begingroup\$ 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? \$\endgroup\$
    – rcplusplus
    Dec 26 '17 at 23:22
  • \$\begingroup\$ @rcplusplus Pretty much, though I don't think anyone needs 15mA these days for an indicator. Are you sure 5mA isn't bright enough? \$\endgroup\$ Dec 26 '17 at 23:59
  • \$\begingroup\$ @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! \$\endgroup\$
    – rcplusplus
    Dec 27 '17 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.