Arduino Forum

Using Arduino => General Electronics => Topic started by: legonick22 on Mar 12, 2015, 03:13 pm

Title: Using Resistors with LEDs
Post by: legonick22 on Mar 12, 2015, 03:13 pm
I often see people online attach a resistor to each individual LED when connected to the Arduino.

Whenever I use multiple LEDs, I tie them all to common ground with a single resistor, since I only have a few 1k resistors.

Either way, it seems to work the same for the LEDs. Is there any problem with the common-ground solution I have found?
(http://forum.arduino.cc/index.php?action=dlattach;topic=307739.0;attach=118202)

(http://forum.arduino.cc/index.php?action=dlattach;topic=307739.0;attach=118204)
Title: Re: Using Resistors with LEDs
Post by: russellz on Mar 12, 2015, 03:25 pm
OK if you only light one LED at a time.  If you light all three they will be significantly less bright - perhaps that's what you want.

Russell.
Title: Re: Using Resistors with LEDs
Post by: legonick22 on Mar 12, 2015, 03:49 pm
Lower brightness is kind of a good thing for me--my LEDs are blinding!

Why would it make them all dimmer?
Title: Re: Using Resistors with LEDs
Post by: Grumpy_Mike on Mar 12, 2015, 03:50 pm
Quote
Either way, it seems to work the same for the LEDs.
No it doesn't.
If you think it does then you are not testing it correctly.

You will get no sympathy or support for such an idea round here because we know what we are talking about on this forum and that idea is just unbelievably wrong.

Quote
I often see people online attach a resistor to each individual LED when connected to the Arduino.
That is because these people know what they are doing unlike you.

Quote
since I only have a few 1k resistors.
Well at $0.01 each they are expensive ain't they.
Title: Re: Using Resistors with LEDs
Post by: legonick22 on Mar 12, 2015, 03:56 pm
If you don't mind, please explain to me why I am wrong, instead of talking like that.
Title: Re: Using Resistors with LEDs
Post by: Grumpy_Mike on Mar 12, 2015, 04:19 pm
Quote
instead of talking like that.
For what you say I will talk how I like. You should not try and propagate your totally wrong ideas here trying to mislead beginners. Especially so when the slightest research into this would have pointed to the error of your ways, but no you were too lazy and thought that you had invented something that had eluded electronic engineered for 40 years. I see you have 48 posts so you are not entirely a stranger to how things work here. If you are going to give advice here, it has to be correct or people will jump on you like a ton of bricks.

Quote
please explain to me why I am wrong
1) Just try having one red LED and the others a different colour. Light up the red one then see none of the others will light when the red one is on. This is because it takes a certain voltage before an LED can come on and the red LED is the lowest voltage and it prevents any of the others coming on.

2) Do you know the voltage / current characteristics of an LED? They are non linear devices. Read this to see.
http://www.thebox.myzen.co.uk/Tutorial/LEDs.html (http://www.thebox.myzen.co.uk/Tutorial/LEDs.html).

3) The current in an LED circuit is controlled by the resistor. If you have one LED on then that gives you a certain current. Two LEDs with just the one resistor gives you the same current but now split between two LEDs, so it will not be as bright. But worse than that the LEDs will not share current equally so one will get more current that the other and so they will not be the same brightness. This inequality will change with the age of the LED and with the temperature. It will also be different on different individual LEDs.
Title: Re: Using Resistors with LEDs
Post by: DBW1341 on Mar 12, 2015, 08:12 pm
Quote
Either way, it seems to work the same for the LEDs. Is there any problem with the common-ground solution I have found?
Legonick, while the setup you have "seems" to work for you, without knowing the specs, you just had good luck.  Whether you set up your LEDs in series or parallel just depends on your hardware and your needs.  A really good site for determining a good and workable setup for your LEDs is led.linear1.org/led.wiz (http://led.linear1.org/led.wiz).  You should also listen to surly, I mean Grumpy_Mike, and purchase more resistors.  Grab a lot and many different values because no matter how many you have, you'll find you never have quite the one you want.
Title: Re: Using Resistors with LEDs
Post by: JoshD on Mar 12, 2015, 08:16 pm
Think of it this way.  If you have 3 LEDs that are rated for 20ma, you could choose a resistor that'll allow 60ma to flow through.  That'll power all 3 LEDs just fine using one resistor (assuming they're perfectly matched and draw exactly the same amount of current each).  Then you turn one LED off, and suddenly the other two are getting 50% more power than they're rated for.  Then you turn another LED off, and the last remaining one will be drawing double what it's rated for.  Well, it will for a split second before it burns out, anyways.
Title: Re: Using Resistors with LEDs
Post by: polymorph on Mar 12, 2015, 10:12 pm
Think of Grumpy_Mike as a hazing that is rarely incorrect.

I have found it expedient to buy mixed packs of resistors. And then when I notice I am using a lot of a few values, I may order large-ish quantities of those resistors.

It is when you only buy a few at a time that they seem expensive.

Same for bypass capacitors in the range of 1nF to 100nF.
Title: Re: Using Resistors with LEDs
Post by: aarg on Mar 13, 2015, 12:19 am
Lower brightness is kind of a good thing for me--my LEDs are blinding!
Many of today's LEDs are vastly more efficient than the original 20th century ones. But a lot of "circuit recipes" are from the old days. People wanted to get as much brightness out of them as possible because they weren't very bright to begin with. So the circuit values reflected a close to maximum "safe" value. 20 mA was very common, since a lot of LEDs had max current of 25 or 30 mA.

As the efficiency of many LEDs now allows outputs in the range of 1000-2000 mcd (even for a 3mm), the old circuits produce a somewhat blinding light if those are used. Sometimes this is a good thing. If it's just an indicator light, sometimes that's overwhelming.

I got on my thinking hat, and started using less current. It worked so well, I started to aim for the most efficient LEDs I could find. It really benefited some circuits by using less power, and loading outputs less. Sometimes I could even get away with a 10k resistor at 5V, and get about the same brightness that a 1984 LED gave with 270 ohms (in fact, that was for a 1984 computer restoration project).

People should stop blindly copying old circuits and look around at what's available today.
Title: Re: Using Resistors with LEDs
Post by: charliesixpack on Mar 13, 2015, 12:50 am
If I understand you correctly, you are putting several LEDs in parallel and connecting them in series with only one resistor.  If you can live with the LEDs being of unequal brightness this is perfectly OK. 

There is a reliability exposure if a significant fraction of the LEDs stop conducting (burn out) in which case the remaining LEDs will carry additional current.  For hobby applications, no problem.
Title: Re: Using Resistors with LEDs
Post by: aarg on Mar 13, 2015, 01:06 am
If I understand you correctly, you are putting several LEDs in parallel and connecting them in series with only one resistor.  If you can live with the LEDs being of unequal brightness this is perfectly OK. 

There is a reliability exposure if a significant fraction of the LEDs stop conducting (burn out) in which case the remaining LEDs will carry additional current.  For hobby applications, no problem.
No you don't understand. legonick22 is switching the LEDs on and off.
Title: Re: Using Resistors with LEDs
Post by: Grumpy_Mike on Mar 13, 2015, 08:45 am
For hobby applications, no problem.
Would you cair to defend that remark? Last time I looked the laws of physics were the same if you are doing a hobby or not.
Title: Re: Using Resistors with LEDs
Post by: JimboZA on Mar 13, 2015, 08:57 am
Would you cair to defend that remark? Last time I looked the laws of physics were the same if you are doing a hobby or not.
I think he means that in a hobby project it migth not matter if an LED fails, not that some parallel set of hobby-laws will prevent it burning out. In the real world, it could literally be a train smash if an LED failed although one would hope there was some redundancy.
Title: Re: Using Resistors with LEDs
Post by: Grumpy_Mike on Mar 13, 2015, 10:39 am
Ah the casual indifference to component abuse and destruction. Never could get into that mind set myself.

A bit like saying my toadstool pizza is fine as I am not selling it, it's only a hobby.

My last wife I beat to death because she wouldn't eat her "miniature mushroom" pizza. 
Title: Re: Using Resistors with LEDs
Post by: charliesixpack on Mar 13, 2015, 12:46 pm
Would you cair to defend that remark? Last time I looked the laws of physics were the same if you are doing a hobby or not.
I am not putting my hobby project in a situation where it might be used to do surgery on someone.  My hobbies are to please only me.
Title: Re: Using Resistors with LEDs
Post by: legonick22 on Mar 13, 2015, 04:22 pm
Boy, that escalated quickly... I only wanted an answer to something that seemed counter intuitive.

I constructed a test sketch that turns 3 LEDs on in off in every possible combination, using a separate 200 ohm resistor for each cathode (I have lots of those!)  LED brightness never changed.

I then tried using a single 1k Ohm resistor and 2 200 ohm resistors in series tied commonly to each cathode. Each turned on fine, but I could not turn on all 3 at the same time. Too much current, I guess.

I'm going to spring for some 1k resistors (I know, my maker shopping list is quite long right now...), but I find it strange that it worked with the ArduinoISP sketch, but not this test sketch.

A note to Grumpy_Mike: I'd greatly appreciate it if you wouldn't try to "haze" me. I am not trying to "mislead beginners" and I don't deserve for anybody to "come down on me like a pile of bricks". Simple questions deserve simple answers, and I don't merit insult, even if perhaps my question is ridiculous.
Title: Re: Using Resistors with LEDs
Post by: charliesixpack on Mar 13, 2015, 05:29 pm
If you are using 200 ohms in series with one LED you must use 200/3 ohms in series with three LEDs if you are connecting the LEDs in parallel and expect to keep the light intensity the same.  You must use the equivalent of three 200 ohm resistors in parallel since you are using three LEDs in parallel.  If I understand you correctly you are attempting to use a higher value resistor when you connect the LEDs in parallel.  This is the opposite of what is required.
Title: Re: Using Resistors with LEDs
Post by: polymorph on Mar 13, 2015, 09:04 pm
If you put different colors in parallel, only the lowest voltage LED will turn on. And hog all the current.
Title: Re: Using Resistors with LEDs
Post by: Grumpy_Mike on Mar 13, 2015, 09:15 pm
If you put different colors in parallel, only the lowest voltage LED will turn on. And hog all the current.
As I said in reply #5
Title: Re: Using Resistors with LEDs
Post by: polymorph on Mar 13, 2015, 10:12 pm
It seemed to bear repeating.
Title: Re: Using Resistors with LEDs
Post by: Grumpy_Mike on Mar 13, 2015, 10:20 pm
Indeed it does.  :)
Title: Re: Using Resistors with LEDs
Post by: nickgammon on Mar 14, 2015, 12:44 am
LED brightness never changed.
Our eyes do not perceive brightness linearly.

See http://www.telescope-optics.net/eye_intensity_response.htm (http://www.telescope-optics.net/eye_intensity_response.htm)

From that:

Quote
In its basic form (Weber law), this implies that eye response to object luminance, as brightness discrimination, is not proportional to its actual (physical) intensity level; rather, that it changes with the intensity level, remaining nearly constant relative to it. This, in turn, under assumption that the relative value of just noticeable difference in brightness sensation is a unit of the sensation change, means that the perceived object brightness changes with the logarithm of object's actual brightness.
So for one thing, your perception changes as the log of the actual brightness, and secondly, depending on how you conducted the experiment, they may have "seemed" same if there was a pause between different tests.

Just as an experiment, I hooked up a LED connected to a 5V supply via a resistor substitution gadget. I could barely tell the difference in brightness between 100 ohm and 1k although the current must have varied by 10 times.

Certainly, small changes were imperceptible, even 820 ohms to 220 ohms.

So the "it seems to work" doesn't really hold up here. Now if the LEDs are all the same, you might get away with sharing a 1k resistor, but honestly, it is best to do it properly.

A while ago I made a clock ( here (http://www.gammon.com.au/forum/?id=11165) ) where I lazily shared a current limiting resistor for all of the segments of a 7-segment display. That should work, huh? The trouble was, the more segments that were on, the dimmer it got. So for example, an 8 (all segments) was noticeably dimmer than a 1 (two segments).

So even for a hobby gadget, the results are just annoyingly noticeable when you finish the project, if you cut corners.
Title: Re: Using Resistors with LEDs
Post by: nickgammon on Mar 14, 2015, 12:46 am
You can even see this effect in this photo of it:

(http://www.gammon.com.au/images/Alarm_clock_photo.jpg)
Title: Re: Using Resistors with LEDs
Post by: Grumpy_Mike on Mar 14, 2015, 06:07 pm
My hobbies are to please only me.
Is this one of yours then?
Title: Re: Using Resistors with LEDs
Post by: pwillard on Mar 14, 2015, 06:59 pm
Quote
People should stop blindly copying old circuits and look around at what's available today.
This comment sort of bugged me as I would beg to differ.  5 minutes of hunting on Instructables will show you many more of today's fools giving bad advice as compared to people who learned how to be good techs when a "super sale" on LED's meant you got 5 for $1.00.    As Grumpy_Mike said, this is about physics and that doesn't really change.  Good electronics technician bench top practices have not drastically changed either.

 Sure, *some* LED's are brighter, like the ones who's datasheet says "1000MCD @ 10mA with 2.1V forward voltage" but that is... wait for it... "datasheet and device specific".  Many LED's operate at what I would call normal brightness versus the trendy "blind a gnat at 200 feet" brightness but it comes down to 1) buying the right part and  2) "Oh My Gosh" reading whatever data is available about the LED.  It might even have a datasheet if you selected and bought it from a reputable vendor.

So here is my point...

Different color LEDS are made varying the semiconductor content in the die.  This different "content" can mean that LED's require different voltages and current to operate most efficiently (as Grumpy_mike mentioned).  It is these parameters that guide the designer/hacker/parts-abuser in determining the correct current limiting resistor for a specific device and using just any just any old resistor part lying around (or none at all)  will only get you so far. 
Title: Re: Using Resistors with LEDs
Post by: aarg on Mar 14, 2015, 11:03 pm
This comment sort of bugged me as I would beg to differ.
PWillard, I'm puzzled because I see little difference in what you're saying, from what I said. Or at least, they may address different subjects.

But... a data sheet can't tell you the correct value of a limiting resistor. It can only tell you the maximum allowable and typical current values. My point was that the minimum is a user choice.

By "look around", I didn't mean on forums. :)
Title: Re: Using Resistors with LEDs
Post by: raschemmel on Mar 15, 2015, 08:39 am
There's not much to be said for the OP's laziness. He would have a hard time defending his approach on the grounds he can't afford the additional resistors. To even make a statement on the forum like:
Quote
since I only have a few 1k resistors.
really leaves one shaking their head. What's the problem, you can't afford more or you don't know how to find them ?

Nevermind that 1 k is the wrong value. We can address that when he learns to wire his circuit correctly.
Title: Re: Using Resistors with LEDs
Post by: Paul__B on Mar 15, 2015, 08:57 am
Nevermind that 1 k is the wrong value. We can address that when he learns to wire his circuit correctly.
Is it wrong?

At least you can't do much damage with 1k. (https://community.logos.com/cfs-filesystemfile.ashx/__key/CommunityServer.Components.ImageFileViewer/CommunityServer.Discussions.Components.Files.28/4011.f_5F00_tongueincheek.gif_2D00_550x0.jpg)
Title: Re: Using Resistors with LEDs
Post by: raschemmel on Mar 15, 2015, 09:03 am
Quote
Is it wrong?  
Let me check:

Let Vcc = 5V
Let LED Vf=2.3V @ 20 mA
5V - 2.3V = 2.7V
RCL = 2.7 V/0.020 V = 135 ohms


1 k != 135 ohms

Note: The OP's using RGB leds so his results (forward voltages, all different for R, G & B) may vary.

Yes, it's wrong.
Title: Re: Using Resistors with LEDs
Post by: Paul__B on Mar 15, 2015, 01:22 pm
1 k != 135 ohms
No, but with modern LEDs 2.5 mA will be plenty visible but will not burn your eyes.  And it certainly won't burn anything else.  :smiley-lol:
Title: Re: Using Resistors with LEDs
Post by: raschemmel on Mar 15, 2015, 04:47 pm
A LED can't burn your eyes or they wouldn't sell them.
Title: Re: Using Resistors with LEDs
Post by: aarg on Mar 15, 2015, 11:15 pm
Look at the value of LED current limiting resistors RN2A, RN2B and RN2C on the UNO. 1.0K.

;)
Title: Re: Using Resistors with LEDs
Post by: nickgammon on Mar 15, 2015, 11:32 pm
Nevermind that 1 k is the wrong value. We can address that when he learns to wire his circuit correctly.
As I mentioned earlier when I tested with different resistances, I could hardly tell the difference visually between 1k and 100 ohms. So 1k would "work" and use less current.
Title: Re: Using Resistors with LEDs
Post by: raschemmel on Mar 15, 2015, 11:36 pm
Quote
100 ohms. So 1k would "work" and use less current.
can't argue with that
Title: Re: Using Resistors with LEDs
Post by: christop on Mar 15, 2015, 11:42 pm
A LED can't burn your eyes or they wouldn't sell them.
I don't think he meant it literally. Super-bright LEDs (particularly the blue ones, in my experience) really are quite bright unless there's very little current--a milliamp or so--running through them. They're bright enough to be painful and cause at least temporary blindness if you look directly into the LED.
Title: Re: Using Resistors with LEDs
Post by: raschemmel on Mar 15, 2015, 11:46 pm
Quote
They're bright enough to be painful and cause at least temporary blindness if you look directly into the LED.
Oh, I didn't know that. Maybe that's why I can't see out of my right eye... ;D
Title: Re: Using Resistors with LEDs
Post by: christop on Mar 15, 2015, 11:51 pm
Oh, I didn't know that. Maybe that's why I can't see out of my right eye... ;D
"Caution: Do not look into laser LED with remaining eye." :D
Title: Re: Using Resistors with LEDs
Post by: Paul__B on Mar 16, 2015, 04:32 am
Look at the value of LED current limiting resistors RN2A, RN2B and RN2C on the UNO. 1.0K.
And they are annoyingly bright!

Especially on some of my Nano clones with a white "L" LED.

Having a bright power indicator is unnecessarily distracting.
Title: Re: Using Resistors with LEDs
Post by: JimboZA on Mar 16, 2015, 05:36 am
I've had some new leds resistored down to something like 5mA and still too bright for the purpose at the time. And on one of my DFR shields I stuck a piece of card over an indicator: the light spilling out the side is more than enough to say "I'm on"....
Title: Re: Using Resistors with LEDs
Post by: raschemmel on Mar 16, 2015, 05:42 am
What can I say, I like bright lights and I don't use batteries unless I need to. (-:
Title: Re: Using Resistors with LEDs
Post by: electricalhobbyist on Mar 18, 2015, 04:07 am
depending on the total current the LED will consume, at a certain current, the LED will not light. make sure to calculate the maximum possible current that will flow in the resistor. LED has a minimum voltage to work..
Title: Re: Using Resistors with LEDs
Post by: raschemmel on Mar 18, 2015, 04:45 am
Quote
LED has a minimum voltage to work..
AKA "Forward Voltage" (Vf)