19
\$\begingroup\$

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?

\$\endgroup\$
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ – ppvi Feb 16 '10 at 14:11
26
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ learned something new today; you have my upvote :-) \$\endgroup\$ – JonathanD May 27 '10 at 14:06
  • 4
    \$\begingroup\$ Keep in mind with this method it is only possible to have N-1 LEDs on at a time. \$\endgroup\$ – AngryEE Mar 19 '11 at 13:37
  • 2
    \$\begingroup\$ The jimmieprodgers.com link in this answer is loaded with viruses. \$\endgroup\$ – Vivek Maharajh Jun 18 '16 at 4:13
  • 1
    \$\begingroup\$ @vivekmaharajh: I replaced the link with a link to an archive.org copy of the original page. \$\endgroup\$ – Dave Tweed Mar 18 '17 at 13:14
13
\$\begingroup\$

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.

\$\endgroup\$
7
\$\begingroup\$

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.

\$\endgroup\$
6
\$\begingroup\$

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)

enter image description here

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – supercat Mar 10 '11 at 7:35
4
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Can you clarify on what sort of circuit you are suggesting here? Emitter follower is a BJT topology. \$\endgroup\$ – Kevin Vermeer Mar 19 '11 at 1:51
  • \$\begingroup\$ @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. \$\endgroup\$ – supercat Mar 19 '11 at 3:17
0
\$\begingroup\$

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?

\$\endgroup\$
  • 2
    \$\begingroup\$ No, he's cheating by using a an arduino mega. :) The mega has many more IO pins than a normal arduino. \$\endgroup\$ – Christopher Biggs Mar 10 '11 at 12:56
  • \$\begingroup\$ @unixbigot - Sad, I had hoped to see a cool hack involving reuse of the reset pin for LED driving, or diode drop use.. \$\endgroup\$ – Kevin Vermeer Mar 19 '11 at 4:32
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Kevin Vermeer Mar 19 '11 at 4:33
  • \$\begingroup\$ @KevinVermeer: Link fixed by pointing to archive.org copy of the original page. \$\endgroup\$ – Dave Tweed Mar 18 '17 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.