Superbright LEDs and Aruduino Duemilanove

Hey everyone,

I'm having a bit of trouble figuring out how to power/control multiple LEDs with my Arduino Duemilanove. I've read countless forum posts describing solutions which involve multiplexing, shift registers, and the best-sounding solution - transistors.

However, I am fairly new to the world of electronic components, and am hoping somebody can guide me to get this right on the first try, without frying my board or LEDs.

Here are the specs I'm dealing with:

According to the Arduino Datasheet, the max current per I/O pin is 20mA, and the max for the board is 200mA.

Here's what I need to run:

  • 5 LEDs in parallel from one PWM pin (so they can be simultaneously faded on or off using a slide potentiometer on separate pins) - I need two sets of this setup to function independently
  • 10 LEDs in parallel, also needing to be faded in unison from a third PWM pin
  • Lastly, I need to power 2 LEDs from a fourth pin

I know it's relatively simple, but if somebody is willing to provide a solution, or even better, a schematic and suggested components I need, I would be SO appreciative. If I'm missing any info here, let me know.

TS

The power source I'm looking at using is 9V. Possibly a single battery for each individual set of LEDs. Space is kind of limited, and I need the entire setup to be portable.

If you have any other suggestions, I'm all ears.

Here is another thread from a clueless person.
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285033397/25#25
In your case (3.5 V forward voltage, recommended 12 V supply) you should take 68 ohms resistors for a string of three LEDs.

When you say "9V battery" I began to tremble. I hope you are not thinking of what I think you do. Add up the current you need (=current *time) and compare it to the battery capacity (mAh).

LEDs in parallel is a bad option.

Tell us why!

I'm not the right one to do it- when dealing with components and tolerances, I'm notorious for the "blue smoke diagnostic" method.. but the site could REALLY use a definitive no-brainer circuit library, the ones that are needed over and over. LED driver via transistor (with both sink and source configuration and WHY), a good explanation of what a Pullup resistor is and why we're happy they are built in, a basic op-amp setup for microphone input, and the basic use of optoisolators and voltage dividers. In reading the forums, these same needs arise over and over, re-inventing the wheel is a grand hobby, though not very productive.

However, you will then be inviting people like me to re-invent the wheel in a more asthetically pleasing and easy to carry rectangular shape..

I'd love to see referenced the most common components- 555's, 741's, 2n2222, etc... so that the most likely component that will be found (at the local radio shack or whatever) and the support circuitry then lines up (if we know gain, for example, we can "standardize" the resistor values). If we assume that 2n2222 or direct equivalent will be used for all NPN switching circuits, we'll be right 90% of the time and include the formulas for other transistors to produce the proper values.

I like many others have some electronics background, but fall short in a lot of areas.. many times just fiddling till it works instead of planning and properly designing. A "cheat sheet" of common circuits using the most common components would be a great thing to have.. I for example know driving the LED with a transistor is the right answer, but I would have done it as a current sourced from the pin- a much less robust design, even if it did work. There's plenty of really good engineers here who know better than to do things the (wrong) way I do things...

Other than that, I recommend http://www.allaboutcircuits.com/ as a GREAT reference to electronics in general...

Thanks for all of the responses. After some consideration, I think I've come up with a solution.

For each of the potentiometer-controlled sets of 5 LEDs, I'm going to have a dedicated set of 4 recharchable AA (2300mAh). The potentiometer will be in series with the LEDs, with the bias pin being the only connection to the Arduino. That way, I can use the reading from the batteries to also change the pitch in one of the speakers.

The set of 10 LEDs will also be powered by it's own set of 4 AA batteries.
For this one though, I'll have to use a transistor. Can anyone suggest a particular transistor that would be best for my purposes?

I had read in another forum that the Darlington UN2003 might be an option, but I'm not sure which specific one I need.

@TonyStark: this sounds funny what you have written - maybe someone else can help here.

@focalist: Yes you are right! All those basic things that have really nothing to do at all with microcontrollers, let alone the Arduino! The same need comes in with Software. 60% of request have to do with basic programming, 20% with basic C-knowledge, 10% with slightly advanced concepts. 10% are interesting.

There had been a nice request some weeks ago: What parts to buy to get started
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1283482310/6#6
I have been pretty astonished that this hasn't been commented. I was prepared to defend 80% of it with teeth and claws, and learn 20% of better things :slight_smile:

We have great tutorials e.g. prepared by GrumpyMike.
http://www.thebox.myzen.co.uk/Workshop/Introduction.html

But references to that have to be given continously

I have selected the LEDs, which are described in my initial post. They're 8000 mcd white, with a 3.5 Forward Voltage, and 20mA current draw.

That said, are we now able to determine the transistor I require for 10 of them in parallel?

If you want to run them in parallel, then 10 * 20mA = 200mA. So you need a transistor that will handle at least 200mA. 2N2222 transistors, for example, are good for 600-800mA depending on the particular variety, package, etc. So it would be safe to use a 2222 to switch a 200mA load. You will be wasting a significant amount of power in all those parallel current-limiting resistors, so you may get only 4~5 hours out of your battery.

Can you suggest a better, more power-efficient solution?

Here's a schematic explaining the potentiometer setup:

I'm pretty sure this will work, but I'm not sure I've selected the right resistors for the LEDs.

Also, is there any way to interrupt the power source where the dotted line is using a pin on the arduino? Meaning, what component do I need to put in there to open/close a switch using arduino code?

Sorry, that diagram confirms that the circuit makes no sense. It has no chance of working. The potentiometer is completely wrong for that circuit.

I've actually had a circuit similar to this work quite well - only 3 LEDs in parallel, with a single resistor and a potentiometer in series. The only difference here, is that the centre pin on the potentiometer will give a reading to an analog pin on the Arduino. I have to use the slide potentiometer because I need the brightness of the LEDs to be controlled by a physical motion.

Thanks for the link to the resistor calculator. If you're willing, I'd really appreciate a schematic of how I can set this up using the components I've listed. Thanks for putting up with me.

Hey Richard,

I used the calculator you suggested, and the diagram shows a single resistor in series with the LEDs in parallel - I was told by someone else not to do that... Have I been misinformed? If so, I apparently only need a single 22ohm resistor (I may now be putting 6 LEDs in parallel instead of five) for this circuit. Does that sound accurate?

The circuit may work to send a variable voltage from the pot wiper back to Arduino, but then the LEDs have no function in the circuit at all. You could just connect the 6V battery across the pot with exactly the same effect.

I know I could, but as shown in my schematic, the analog reading will be used to change a pitch in the speaker.

The circuit doesn't work (by that I mean that the LEDs will not light up) because the 20K series resistance limits the current to 0.06mA each, which probably won't even make them visible at all.

Yeah, I'm aware of this as well. It's only 20K at one end of the potentiometer, and 0 at the other, which fades the LEDs from (virtually) off to on.

But, the transistor seems to be the solution to controlling the power from the 6V source to the LEDs. Can you suggest a specific transistor for this purpose? The current here is only 120mA.

Also, since I'm using 6 LEDs with identical ratings, can I assume they'll work properly with the single resistor, or do I have to measure each one?

Thanks Richard. The 2222 is fine, but there seems to be a range of them available online. How do I determine which one is appropriate for these specific components?

Perfect. Actually, I found another post where you had answered the same question, and that solved the problem. I've ordered 10 of them, and found a schematic for how to connect it to the arduino.

The only part of the schematic I'm a little unsure of, is the resistors listed.... It calls for a series-resistor for each LED with a rating of 330ohm, and single resistor with a rating of 1K or 2.2K...

Why are these so high, and why are they powering it from the 5V Arduino power supply?