# How many individual lights can an arduino control

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?

• You need to specify if you want to control one or multiple leds. Also, I would add "avoiding serial control and additional ICs". The answer tends to infinite if refresh rate or hardware parts are not constraints.
– ppvi
Commented Feb 16, 2010 at 14:11

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

• learned something new today; you have my upvote :-) Commented May 27, 2010 at 14:06
• Keep in mind with this method it is only possible to have N-1 LEDs on at a time. Commented Mar 19, 2011 at 13:37
• The jimmieprodgers.com link in this answer is loaded with viruses. Commented Jun 18, 2016 at 4:13
• @vivekmaharajh: I replaced the link with a link to an archive.org copy of the original page. Commented Mar 18, 2017 at 13:14

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)

• Looks like something I saw at the UFO exhibit in Minneapolis circa 1979 or thereabouts, but I remember that as being somewhere around 4096 miniature light bulbs. Does anyone else remember seeing something like that? Commented Mar 10, 2011 at 7:35

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.

See the Microchip datasheets or application notes for the following parts:
SPI - MCP23S08
I2C - MCP23008

If using digital LEDs such as WS2812 aka "Neopixels", a standard Arduino Uno can control up to 600 RGB pixels, without having to multiplex anything :)

The only limitation here is the RAM of the board. A board with more RAM, such as an Arduino Mega that has 8kb of RAM can control up to 2400 pixels, when compared to an Uno which has only 2kb of RAM.

You can find a nice overview here: https://www.eerkmans.nl/powering-lots-of-leds-from-arduino/

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.

• Can you clarify on what sort of circuit you are suggesting here? Emitter follower is a BJT topology. Commented Mar 19, 2011 at 1:51
• @reemrevnivek: See edit above. I'd been mentally tossing around a few variations, and they got muddled together. If one is adding transistors to boost the high-side drive but not the low-side drive, they need to be BJT's. If one were using transistors for both, mosfets might be better. Commented Mar 19, 2011 at 3:17

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?

• No, he's cheating by using a an arduino mega. :) The mega has many more IO pins than a normal arduino. Commented Mar 10, 2011 at 12:56
• @unixbigot - Sad, I had hoped to see a cool hack involving reuse of the reset pin for LED driving, or diode drop use.. Commented Mar 19, 2011 at 4:32
• Your link is dead, and you should probably link to Windell Oskay's answer. It may not seem important when you post, but as more answers appear, your post becomes distant from the other. Commented Mar 19, 2011 at 4:33
• @KevinVermeer: Link fixed by pointing to archive.org copy of the original page. Commented Mar 18, 2017 at 13:19