Ohm's Law & LEDs

I just recently retired & I want to take up electronics as a hobby. I'm a newbie.

One of my electronics books states that LEDs have internal resistance. I hadn't considered that. Also, a connected LED has current flowing thru it.

I have some questions about using Ohm's Law to calculate the value of the current limiting resistor.

I want to get a Mega2560. According to the specs on the website, the DC current of each I/O pin is 40 mA. That's about what is needed to drive an LED.

Please correct me if I am wrong in my calculations.

An LED has a forward voltage & that is subtracted from the DC I/O voltage to derive the voltage value in Ohm's Law. So, for the 2560 that would be 5V minus whatever the forward voltage is for the LED. How do I determine the internal resistance of the LED? Do I hook it up to a digital multimeter (DMM)? Likewise, how do I determine the current flowing thru the LED? Do I hook it up to a DMM or does the LED have to be in a circuit before I hook it up to a DMM? If It has to be in a circuit in order to read the current, then the LED has to have a current limiting resistor which I'm trying to determine the value of! You can see my confusion!

An LED has a forward voltage & that is subtracted from the DC I/O voltage to derive the voltage value in Ohm's Law. So, for the 2560 that would be 5V minus whatever the forward voltage is for the LED. How do I determine the internal resistance of the LED?

First part is right, second part's answer is "you don't".

You take that reduced voltage (let's call it 3, being 5-2 say), which is the voltage we need to "lose" across our series resistor, and divide that by the allowed current, let's call that 20mA to be safe. (That's Ohm's Law in action: volts / current = resistance.) The result is the resistance we need: so in this case it's 3 / 0.020 = 150 Ohms. Next available higher is 220, so use that. It'll reduce current which is good, but make no discernable difference to the brightness.

Welcome to your new hobby....

You indeed could power an led up to 40ma from each pin...

But you'll quickly find that it won't work after several being powered, because there's a total current it can supply with all the pins sourcing current..... in other words if you plan on creating a light decorated object, use transistors.

Macnerd:
I want to get a Mega2560. According to the specs on the website, the DC current of each I/O pin is 40 mA. That's about what is needed to drive an LED.

Nope.

That's when the pin starts to burn up, not a working, long-term current.

Macnerd:
Please correct me if I am wrong in my calculations.

An LED has a forward voltage & that is subtracted from the DC I/O voltage to derive the voltage value in Ohm's Law. So, for the 2560 that would be 5V minus whatever the forward voltage is for the LED. How do I determine the internal resistance of the LED? Do I hook it up to a digital multimeter (DMM)? Likewise, how do I determine the current flowing thru the LED? Do I hook it up to a DMM or does the LED have to be in a circuit before I hook it up to a DMM? If It has to be in a circuit in order to read the current, then the LED has to have a current limiting resistor which I'm trying to determine the value of! You can see my confusion!

If you're going to do it that way you need a selectable resistor: decade resistance box - Google Search

(nb. NOT a potentiometer)

But really you need to learn how to build a circuit that sets a current. Connect the LED to one of those and the correct voltage will appear across it like magic.

Next standard value up from 150 is 180, then 200, then 220.

If you read the datasheet, you will see that only 4.2V is guaranteed out as a high when the load is up to 20mA, and it will drop off from there:

Section 31 of 2560 datasheet:
VOH, Output High Voltage, IOH = -20mA, VCC = 5V: Min voltage = 4.2V
20mA is the max continuous for many LEDs, not 40mA. Some LEDs will support higher currents but only when pulsed on, typically with limits such as:

Peak Forward Current (1/10th duty cycle, 0.1ms pulse width)

So for a typical Red LED with Vf of 2.2V and current limit of 20mA:
(4.2V - 2.2V)/.02A = 100 ohm
You can make some measurements directly and confirm:
Voltage at the header pin
Voltage across the LED
Voltage across the resistor
Put the meter in mA mode and put the leads in series between the header pin and the LED.
The output pin will have some variation, the LED will have some variation (say it was spec'ed to be 2V to 2.4V, 2.2V typical), the resistor will have some variation (say 5%).

Worst case, use 5V, use the lower value of the LEDs Vf range, and use the resistor less it's tolerance.
(5V - 2V)/(100 - 5% ohm) = 31.6mA -> danger territory for the LED, runs hotter and shortens life. Adjust the resistor accordingly. 150 gets you back into safe current level.

My book Arduino for Teens goes into basics like this, available at Amazon.com

How do I determine the internal resistance of the LED?

The issue is... LEDs are nonlinear... The resistance of an LED (or any diode) changes when you change the voltage across it (or the current through it). Once there is enough voltage to turn the LED on, the resistance drops dramatically as you increase the voltage. (And with a little too much voltage, you'll get WAY too much current, and you'll kill the LED.)

Since the resistance of an LED is "unreliable", it's rarely useful to know and we don't usually consider it when designing circuits.

But, you CAN calculate the resistance under known-static conditions. The current through the series resistor is the same as the current through the LED. So, you can measure the voltage across the resistor and calculate the current. Then measure the voltage across the LED, and you have your 2 values needed to calculate the LED's resistance with Ohm's Law.

If you want to do an experiment, you can try making the above measurements & calculations with two different series-resistor values to see how the resistance of the LED changes as the current through it changes.

If you do that experiment, you'll notice that the voltage across the LED (and across the resistor) changes very little with a different resistor (you might not measure any difference at all). For this reason, LEDs are considered "constant voltage" devices.

DVDdoug:
Then measure the voltage across the LED, and you have your 2 values needed to calculate the LED's resistance with Ohm's Law.

No you don't. Your description is confused.

The equivalent of a LED is indeed a voltage drop plus a resistance. The resistance does vary a little with the current flowing, but not so much. It is because the resistance is so small that small variations in the voltage correspond to large variations in current, but this in no way indicates that the LED is non-linear as it basically is not.

To determine the approximate resistance you have to do two measurements of the voltage across the LED at two current levels, and the resistance is the difference in voltage divided by the difference in current.

I just recently retired & I want to take up electronics as a hobby. I'm a newbie.

Let's concentrate on these words and try to help this gentleman:

Forget on the LED having an internal resistance (this would be high degree electronics: is not the case): for your purpose is much better to think on the LED being a "reverse" battery that subtracts a fixed voltage from your other power supply (the 5V coming from the arduino).

The operating voltage for every LED is not the same (it varies from 1.5 to 2.5 Volts, aproximately). You have to be prepared for the worst case scenario, being this that the LED operates at 1.5 Volts (the larger it -the LED- substracts the lower the difference). In this case you have 3.5 Volts available to apply Ohm law => I = V / R, being "R" the external resistor you have to connect in series to get the Amperes you want (need).

For a standard LED 20 mA would do, so R = V / I => R = 3.5 V /20 mA = 1750 Ohm. Take the inmediately bigger value (1800 Ohm = 1k8).

The best is to measure the voltage accross the resistor (or the LED) and recalculate. If the LED DOES NOT brigth enough you can try with a little less (1k6, 1k5, . . . ): be careful.

Regards

vffgaston:
For a standard LED 20 mA would do, so R = V / I => R = 3.5 V /20 mA = 1750 Ohm. Take the inmediately bigger value (1800 Ohm = 1k8).

...except that even within the same batch the LEDs will be specified as 3.2-3.6V (or whatever).

With no current control, 0.2V extra could mean 40mA instead of 20mA (check out the graphs on a few LED datasheets sometime...)

This is why you shouldn't be doing calculations like the one you just did. Not if you want any sort of precision/reliability.

It honestly does not matter!

Almost all of the current breed of LEDs are high efficiency. I dislike such nonsense terms as "super-bright" and "ultra-bright" - it merely means that older LEDs were actually very poor efficiency and the current ones are in fact, efficient.

They will in general, give excellent brightness at 10 mA or less, so a 330 ohm resistor will be absolutely fine and can neither overload the LED or the Arduino port pin (even if placed from the port pin directly to ground). So just use 330 ohm resistors for starters. For high power LEDs such as 300 mW, 500mW, 1W and so on, you need driver transistors, driver circuits and more careful calculations, but not for simple indicator LEDs.

It is difficult to measure current in 5V circuits with LEDs with common multimeters as the resistance of the meter itself is comparable to the dropper resistor in use. But it is not necessary - just measure the voltage across the 330 ohm resistor and calculate the current. If you want to make the current something different, change the resistor in proportion. This will be an approximation; not because of the internal resistance of the LED, but because of the internal resistance of the Arduino port, which is probably in the order of 40 ohms (I must try this sometime!), so you would probably need to change the resistor value plus 40 ohms in proportion to the desired current change.

For a standard LED 20 mA would do, so R = V / I => R = 3.5 V /20 mA = 1750 Ohm. Take the inmediately bigger value (1800 Ohm = 1k8).
You may have a math error.
20mA in decimal is .02A. There are 1,000 mA in 1 A. (20 mA/1,000 mA = .02) Therefore, 3.5 V/20 mA = 175 Ohms.

It is because the resistance is so small that small variations in the voltage correspond to large variations in current...
That explains the voltage-current curves that I've seen on the internet. I've wondered why a small increase in voltage results in a large increase in current. That's why the websites that I've seen recommend a constant current circuit.

...except that even within the same batch the LEDs will be specified as 3.2-3.6V (or whatever).
Worst case, use 5V, use the lower value of the LEDs Vf range, and use the resistor less it's tolerance.
(5V - 2V)/(100 - 5% ohm) = 31.6mA -> danger territory for the LED, runs hotter and shortens life. Adjust the resistor accordingly. 150 gets you back into safe current level.
I hadn't considered that. I hadn't considered the resistor's tolerance & the variations in the current & voltage of the LED. It is very evident to me that I have a lot to learn about electronics!

Peak Forward Current (1/10th duty cycle, 0.1ms pulse width)
I want to PWM the LED. 1/10th duty cycle is equivalent to 10% duty cycle isn't it?

But you'll quickly find that it won't work after several being powered, because there's a total current it can supply with all the pins sourcing current..... in other words if you plan on creating a light decorated object, use transistors.
In the beginning, I want to experiment with single-color LEDs. Eventually, I want to make an RGB LED matrix. This is another area that confuses me. On the internet, I've seen LED driver ICs & transistor drivers. I've seen transistor sourcing drivers & transistor sinking drivers. The majority of websites that I've seen recommend constant current drivers. So, does it make any difference if the transistor driver is current sourcing or current sinking? If I have 8 LEDs & each LED requires 20 mA, then 20 X 8 = 160 mA. Do I apply a current of 160 mA to the string of LEDs? Does it matter if the string is connected in series or parallel?

Macnerd:
Do I apply a current of 160 mA to the string of LEDs? Does it matter if the string is connected in series or parallel?

Try not to get too hung up on all of the above chatter, lots of overkill discussion for a new person to absorb. You can easily power a bunch of LEDs with your arduino.

Look for a basic tool like this to make resistor selection for an LED easy; there is even a calculator for series/parallel powering. You MUST burn up a LED or two; it is a rite of passage so don't just buy one!

Pick a project out there that takes you through from start-to-finish and learn. Since there are many ways to drive an LED, you can start with one way that intrigues you and matches your skills and budget.

You may not want to start with an 8x8x8 cube, for example... perhaps learn a shift register or two or three and do some exciting things with 8, 16 or more LEDs. Or buy a few transistors and learn transistor switching.... Learn PWM...

Selecting a resistor for your LED isn't as complicated as all of the above suggests, in my opinion. It might be one of the easier things you take on here.

Have fun!

Paul__B:
Almost all of the current breed of LEDs will in general, give excellent brightness at 10 mA or less, so a 330 ohm resistor will be absolutely fine and can neither overload the LED or the Arduino port pin (even if placed from the port pin directly to ground). So just use 330 ohm resistors for starters.

This too.

The idea that LEDs have to run at exactly 20mA is ludicrous. You only need that if you're building a flashlight or lighting a room and want maximum output.

If you're looking directly at the LED then you can use much less than 20mA. The human eye is logarithmic. 10mA (or even 5mA) is plenty.

For power-indicator LEDs I often put in a 2k resistor. That would put them down in the single-milliamp range. They're still perfectly visible (but they don't keep me awake at night and I don't get an afterimage every time I look at the device).

For a standard LED 20 mA would do, so R = V / I => R = 3.5 V /20 mA = 1750 Ohm. Take the inmediately bigger value (1800 Ohm = 1k8).
You may have a math error.
20mA in decimal is .02A. There are 1,000 mA in 1 A. (20 mA/1,000 mA = .02) Therefore, 3.5 V/20 mA = 175 Ohms.

Yes: 175 Ohm is the correct answer (In fact I have a 100 Ohm one with an arduino due -3.3 V instead of 5 V). It will ligth with this value: if it brigths enough let this value of resistance; if you want it a little brigther try with 160/150 Ohm.

Regards

**Look for a basic tool like this to make resistor selection for an LED easy; there is even a calculator for series/parallel powering. You MUST burn up a LED or two; it is a rite of passage so don't just buy one! **
The wizard is for series-connected LEDs. I've seen a lot of circuits on the internet where the LEDs are connected in series. I want to be able to address individual LEDs.
I suppose that the ideal would be to individually drive each individual LED. Perhaps transistors would be better than a driver IC because it would be easy to change the values of the components to increase or decrease the output current. The IC would be limited by its maximum output current.

Macnerd:
The wizard is for series-connected LEDs. I've seen a lot of circuits on the internet where the LEDs are connected in series. I want to be able to address individual LEDs.

the link I posted is for single LED's, LED's in series or LED's in parallel. The page I posted is for single LEDs and there is a link for parallel, or series.

the answer to your concerns is "it depends" on your application what you want to do with your LED, wether you want to power off of your Arduino, or by other power source, etc...

I want to be able to address individual LEDs.

Look into getting a MAX7219 as well.
http://www.taydaelectronics.com/catalogsearch/result/?q=max7219
Drive up to 64 LEDs, one resistor (22K or so) and 2 caps (0.1uF , 10uF).
15 brightness levels under software control.
I have a little breakout board also so can wire up the LEDs and run them around to different places.
http://www.crossroadsfencing.com/BobuinoRev17/
Scroll down for a short video

MAX7219-MAX7221.pdf (451 KB)

The IC would be limited by its maximum output current.

As opposed to?
Everything is limited by the amount of current it can provide.

I suppose that the ideal would be to individually drive each individual LED.

If you want individual control of each LED then you do not have much choice apart from matrix multiplexing.

Matrix, or shift registers with 1 output per LED.
74HC595, TPIC6B595, or PWM per output with WS2803, TLC5940 as examples.
Really depends on quantity to be controlled.

The IC would be limited by its maximum output current.
As opposed to?
The IC most likely has a datasheet or specification sheet & most likely there is a maximum output current listed.

I've googled "LED driver IC" & every website that I've visited states that the driver ICs are for industrial & residential lighting & backlighting for displays & stuff like that. Apparently, they aren't meant for hobbyist use. Correct me if I'm wrong.

I'll start off simply by playing around with single LEDs. Then single-color matrices & finally RGB LED matrices.Since ultimately I want to make a RGB LED matrix I will need some kind of driver circuit between the Arduino & the matrix. On the internet, I've seen current sourcing & current sinking circuits. Does it make any difference which one I use between the Arduino & the LEDs?