📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 3 Day orders by 11am ET Friday December 13 📬❄️📦
0

Arduino LED capacity
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Arduino LED capacity

by paulcarver on Mon Nov 10, 2008 1:12 pm

Can someone point me towards a reference that explains the output capacity of the Arduino? I want to make LED "eyes" for a spider costume and I'm planning to create a multifaceted cluster of LEDs in several colors. I want them to shift and shimmer so I need to use as many separate outputs as possible. I assume there aren't enough outputs to create the two dense "clusters" of LEDs that I want so I assume I'll need to put a bunch of LEDs in series and/or parallel attached to each ping.

I haven't bought an Arduino yet but I'm thinking of using the Lilypad Arduino and I'm trying to figure out how many pins can actually be used to light LEDs and how many LEDs I can connect per pin.

I haven't been able to find any clear document that lists all the pins, what each is for, and how much voltage and current each can supply.

I'd like to drive about 30-40 LEDs from a single Arduino with the LEDs split into as many separately controlled groups as possible.
paulcarver
 
Posts: 8
Joined: Mon Nov 10, 2008 12:45 pm

Re: Arduino LED capacity

by trialex on Mon Nov 10, 2008 4:36 pm

If you look at the datasheet for the AtMega168, which is the "brains" of the arduino's, they specify a maximum current source or sink of 40mA per pin, and 200mA per port.

So it's up to you how many LEDs you put on each pin, but you should limit the total current to the above limits.

More popularly, people wanting to use lots of LEDs use transistors on the pins to switch a circuit with a giher mA or voltage cpapacity.

From arduino.cc ...

http://www.arduino.cc/playground/uploads/Learning/multiple_leds2.jpg
trialex
 
Posts: 189
Joined: Mon Apr 03, 2006 6:25 pm

Re: Arduino LED capacity

by westfw on Mon Nov 10, 2008 7:00 pm

The original question is difficult to answer. You can "easily" attach 14 LEDs directly to the 14 digital pins of an arduino. If you use the analog inputs as additional outputs (which is easy), you can expand that to 20. 20 outputs at 10mA each (hitting the chip limit of 200mA) is pretty "comfortable."

You can get MORE leds by using multiplexing (48 or so should be easy), or "Charilieplexing" (182 without using the analog pins.) External transistors or drivers will allow more current (brighter LEDS, or more in parallel or series), fancier external components (latches, specialized driver chips) will allow near-indefinite expansion. The code gets more involved, and LEDs may be slower to update. However, the Evil Mad Scientist Labs' "Peggy 2" is essentially an Arduino with some dedicated external logic (only 4 chips) that is capable of driving 625 LEDs fast enough for interesting animations.

EMSL Peggy 2: http://www.evilmadscientist.com/article.php/peggy2

Instructables on charlieplexing:
http://www.instructables.com/id/How-to- ... rocontrol/
http://www.instructables.com/id/Charlie ... he-theory/
http://www.instructables.com/id/Arduino ... for-Valen/ (uses arduino!)
Arduino Thread on charlieplexing 156 LEDS: http://www.arduino.cc/cgi-bin/yabb2/YaB ... 24481255/0
westfw
 
Posts: 1585
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Arduino LED capacity

by paulcarver on Mon Nov 10, 2008 7:11 pm

That jpg is a good piece of info, thanks. The AtMega168 datasheet is a beast. I'll try to get through it, but there's a lot in there that I have trouble following.

However, it looks like things might be simpler than I thought. I had gotten the impression that there were lots of different sorts of pins, but it looks like it's not so bad. I found this page http://www.arduino.cc/en/Main/ArduinoBoardDiecimila and I think it applies equally well to the Lilypad Arduino.

From this picture http://www.arduino.cc/en/Main/ArduinoBoardLilyPad I can see that there are contacts labeled 0 - 13 so those must be the 14 digital I/O pins and I assume I can use all 14 of them to drive LEDs under independent control. The contacts labeled a0 - a5 must be the 6 analog inputs which I don't have much use for at the moment. The contacts labeled "+" and "-" must be +5V supply and ground, of course.

What did you mean by the word "port"? You obviously intend it to mean something different than "pin", but I'm not clear on the distinction.

Once I actually buy the Lilypads I'll be able to measure the output voltage on each pin, but I assume it would be close to the same voltage as the input voltage which according to the page above should be 2.7-5.5 V. If I'm using LEDs with a voltage drop in the neighborhood of 2V then I should be able to wire two in series with a resistor in the neighborhood of 25 Ohms and power it off of three AA or AAA batteries ( 4.5V = 2 * 2V + (0.5V / 20mA) )

So, 14 I/O pins with two LEDs per pin drawing approx 20mA per LED gives me 28 LEDs total. Since these are "eyes" on the costume and I'd like to make do with one Arduino per costume that means that I can make each eye a cluster of 14 independently controlled LEDs with 15 wires connecting the "eyes" (14 positive and a common ground). The two "eyes" on a costume with light in unison which works aesthetically for what I want.

Have I made any obvious errors in my reasoning?
paulcarver
 
Posts: 8
Joined: Mon Nov 10, 2008 12:45 pm

Re: Arduino LED capacity

by trialex on Mon Nov 10, 2008 7:25 pm

A "port" is a collection of pins that are sort of conencted together inside the AVR chip itself. For example look at this image

Image

digital pins 0 through 4 are connected to port D - indicated by their pin designators PD0 through PD4 shown next to the chip block. Simmilarly digital pins 8 through 13 are port B, and so on.

So yeah you could do it as you have described, because 20mA per pin is always less than 200mA per port, because each port has a maximum of 8 pins

Remember that if you attach stuff (i.e. in your case LEDs) to digital pins 0 and 1 you can no longer use the serial communication tools.

Also remember though that the pins labeled "analog in" also work as digital in/outs, just call them 14 through 19 and use them in the same way as 0 through 13.

In general, it does seem like a waste of the computational power to put two LEDs per pin if you are just going to be turning them on or off in big blocks, but obviously it's the simplest and cheapest way to do it.
trialex
 
Posts: 189
Joined: Mon Apr 03, 2006 6:25 pm

Re: Arduino LED capacity

by paulcarver on Tue Nov 11, 2008 5:29 pm

That chip diagram is very helpful although clearly my brain doesn't work like an electrical engineers since I find their choice of naming and numberings to be perverse and cryptic.

I don't plan to turn the LEDs on and off in large blocks, the goal is to have a lot of visual interest by having the "eyes" glitter as if they were multifaceted insect eyes (yes I know a spider is an arachnid) so I want as many independent LEDs as possible. I'm definitely not going for simply glowing or blinking, but rather complex shifting and sparkling.

Doing two LEDs per pin and making a pair of "eyes" be a matched set driven by a single Arduino just makes aesthetic sense to me. The fact that the analog inputs can be used as outputs is great, that means I can leave 0 and 1 available for programming and still have 17 LEDs per "eye".

I drilled holes in the cap of a Vitamin Water bottle last night and stuck 14 LEDs through the holes. I think 14-17 LEDs mounted in a bottle cap like this is just about the right size and density to form each "eye" for the costume. Then, two bottle caps will be mounted to a ski mask with wires inside the ski mask connecting each LED in one "eye" to a corresponding LED in the other "eye" in series. They "eyes" will glitter and shimmer in unison, but with a complicated pattern.
paulcarver
 
Posts: 8
Joined: Mon Nov 10, 2008 12:45 pm

Re: Arduino LED capacity

by trialex on Tue Nov 11, 2008 5:35 pm

paulcarver wrote:That chip diagram is very helpful although clearly my brain doesn't work like an electrical engineers since I find their choice of naming and numberings to be perverse and cryptic.


As often happens it's a tradeoff between usability and powerfulness - they could have made the names easier to understand, but it would have meant leaving out some information, or taking a lot more space to do it. Once you use the names once or twice though, you get used to it. There is actually a lot of powerful stuff you can do if you start working at the port level, like changes all the pins on a port to whatever you want them to be in one single command, rather than a separate digitalWrite for each pin. Something for the future!

paulcarver wrote:I don't plan to turn the LEDs on and off in large blocks, the goal is to have a lot of visual interest by having the "eyes" glitter as if they were multifaceted insect eyes (yes I know a spider is an arachnid) so I want as many independent LEDs as possible. I'm definitely not going for simply glowing or blinking, but rather complex shifting and sparkling.


Sorry for mis-interpereting what you were saying - sounds like you know exactly what you are doing, and should be an interesting effect!
trialex
 
Posts: 189
Joined: Mon Apr 03, 2006 6:25 pm

Re: Arduino LED capacity

by macegr on Wed Nov 12, 2008 9:09 pm

Why not buy some of the automatic blinking/fading LEDs? On initial powerup they will be in sync, but pretty quickly they'll drift away from each other and give a shimmering effect. The "slow flashing" ones are really nice, they actually fade between colors smoothly, not just blink to red/green/blue.

Here's a few sources, most of which I've tried before:

http://cgi.ebay.com/New-100X-8Kmcd-Slow ... m153.l1262

http://cgi.ebay.com/New-100X-8Kmcd-Fast ... m153.l1262

http://cgi.ebay.com/100-PCS-5mm-8Kmcd-F ... m153.l1262

http://cgi.ebay.com/100-PCS-5mm-8Kmcd-F ... m153.l1262
macetech LLC - http://www.macetech.com
macegr
 
Posts: 292
Joined: Fri Apr 04, 2008 4:46 pm

Re: Arduino LED capacity

by paulcarver on Thu Nov 13, 2008 11:15 am

Thanks for the suggestion, that's certainly a possible alternative. However I think that would give me very limited control, wouldn't it? Sort of "take it or leave it" with no way to adjust the effect?

These "eyes" are for costumes to be worn by dancers for a show opening on December 13. I have one month to get the costumes together. The "blinky-flashy" effect should be pseudo-random, but must not clash with the music or distract from the dancers' movements. The advantage I see with the Arduino is that I should be able to tweak the timing and intensity of the LEDs via software just by adjusting the delays in the sketch and re-downloading. If the blinking is built into the LEDs then I assume that if it's too fast or too slow or whatever then I need to purchase different LEDs and physically rebuild the costumes.

I'm also hoping that the Arduino chips will be reusable for future projects. This particular show only runs for 8 performances, but I'd like to find ways to re-use the same Arduinos in future shows. The "spider eyes" will be disassembled and kept for parts.
paulcarver
 
Posts: 8
Joined: Mon Nov 10, 2008 12:45 pm

Re: Arduino LED capacity

by westfw on Thu Nov 13, 2008 12:39 pm

I have one month to get the costumes together.

Ouch!
Have you seen these:
http://moderndevice.com/8X8display.shtml
8x8 non-multiplexed (BRIGHT), simple interface to Arduino, Arduino code sample included.
westfw
 
Posts: 1585
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: Arduino LED capacity

by MattieShoes on Mon Nov 17, 2008 1:18 am

You could forego the arduino and use a bunch of 555 timer ICs (for less than a buck a piece) and sink and source a pair of LEDs or more on each one.... you can adjust blink rate by adjusting resistor/capacitor values... Heck, I think you can setup the 555 to do PWM and actually fade the lights in and out if you wanted. :-)
MattieShoes
 
Posts: 8
Joined: Sat Nov 15, 2008 10:59 pm

Please be positive and constructive with your questions and comments.