I want to use a regular Arduino board to control LEDs - what is the most lights I can control individually from the board?
Is there a tutorial on how to hook it up?
I believe using Charlie-plexing N lines controls N*(N-1) LEDs. There is a good article on Wikipedia.
A friend of mine, Jimmie P. Rodgers, fit 126 LEDs on an Arduino Shield. He uses charlie-plexing to control the LEDs. Some information on his board is at -- jimmieprodgers.com/2009/12/my-development-process/ (archive.org copy)
At the last Boston Arduino User Group meeting Jimmie P. Rodgers drew a Charlie-plexing diagram as a matrix with labeled nets. Schematics drawn in this manner seemed to do a good job of communicating the concept. I created a couple of similar schematics -- See http://wiblocks.luciani.org/FAQ/faq-charlie-plex.html
You can use Shift Registers (http://en.wikipedia.org/wiki/Shift_register) to get as many parallel outputs from a single serial stream as you want.
You will need to be concerned with your power constraints. I have actually never used an Arduino myself but I am assuming it has a current limit just like PICs do. Also, shift registers will have a current limit themselves. If you run into this, you will need to look at using something like a MOSFET to allow you to control the LEDs without having to pull much power directly from your micro controller.
Any given AVR microcontroller pin is allowed to source up to 40 mA, and the total power supply sourced or sunk by the chip (i.e., at the ground and Vcc pins) needs to be below 200 mA.
Charlieplexing is a great solution for situations where you need lots of LEDs, but can get by with only one LED lit at a time. A standard Arduino board (like a Duemilanove) provides 17 "free" I/O pins, not counting TX, RX, Reset, or pin 13. So, you can hook up 17*16=272 LEDs. This can work well, especially if you're keeping one LED lit, or quickly scanning between just a few. But if you're trying to light the whole matrix with a pattern, you'll find that each is on (slightly less than) 1/272 of the time, so if your drive current were 30 mA at any given moment, each LED's average current would be about 0.1 mA-- pretty dim.
If you don't need that many LEDs but instead need more brightness, traditional multiplexing may be a better option. In this case, you use some of your lines as rows and some as columns in a matrix. If you use a 10 mA LED current, you could define a matrix of 4 columns and 13 rows, where all 4 LEDs in one row can be on at a time, and you scan through the rows. Then each row is on 1/13 of the time at 10 mA current, so the average LED current can be as high as 0.76 mA, BUT you only get 4*13=104 LEDs. (Definitely brighter per LED than with charlieplexing.)
The limit in the last example is the 40 mA per pin on the AVR-- since each row driving pin sources 4x10=40 mA. If you allow external transistors (which can be cheap and small) to be added to the row outputs, then you can avoid that particular limit and go brighter. For example, you could make an 8x9 array, with 8 rows and 9 columns, 72 LEDs altogether. One of the 8 rows is on at a time, selected through the transistor. Up to all 9 LEDs in a given row can be on at a time, driven at 20 mA, so 180 mA comes from the transistor, and you stay under the current limits of the AVR. The average current per LED is now 20 mA/8 = 2.5 mA-- usually reasonably bright.
There's a very nice, detailed tutorial here which includes a section on using an Arduino to run an 8x8x8 LED cube. (Don't miss the YouTube movie they have up)
There are many I/O Expanders out there that use either SPI or I2C buses. With a single MSSP module you can control almost an infinite amount of digital outputs like LEDs.
With 17 I/O pins, seventeen NPN transistors (emitter followers to boost current) there should be no particular problem showing 272 LEDs in arbitrary combinations at 1/17 duty cycle, with average current or 0.7mA (200mA/272), limited by the chip's ability to pull down 200mA at a time. Adding a diode to get a 0.7-volt drop will allow the addition of another 17 LEDs (reducing duty cycle to 1/18), though the brightness won't quite match the other ones.
While Windell Oskay makes a good argument that 104 LEDs is the maximum without adding more transistors, Tom Igoe has posted photos of a matrix of 128 LEDs directly controlled by a single Arduino Mega -- no extra transistors, discrete or integrated.
Is Tom Igoe "cheating" by briefly exceeding the "absolute maximum current per pin" listed in the datasheet?