# Control a large number of LEDs from minimal output pins

I am working on a project that uses an Attiny84 to control a large number of LEDs. The number of LEDs far outnumbers the number of I/O pins. What concepts and principles should I be researching into for a solution?

• Essentially your MCU will send the data serially. There are endless ways to do it, not least of which is a basic shift register. Commented Mar 31, 2023 at 10:52
• A LED strip with hundreds of LEDs controlled by one data wire. How many LEDs you need? Commented Mar 31, 2023 at 10:52
• How to control a maximal number of LEDs with minimal output pins is a completely different and unrelated question to controlling a large number of IO with not minimal MCU pins. It has a completely different answer. Commented Mar 31, 2023 at 10:59
• Have a look at the MAX7219, which is specifically designed for this kind of thing, controlling up to 64 LEDs. Or if your design will accomodate it, WS2812 LEDs, which have circuitry already in them. Commented Mar 31, 2023 at 11:13
• If your LEDs all have the same forward voltage you could look into Charlieplexing nl.wikipedia.org/wiki/Charlieplexing
– Bart
Commented Mar 31, 2023 at 11:47

In general, your MCU will communicate serially. There are endless ways of doing this, from the simplest to the most complex.

## With Shift registers

Here's a shift register (74164)

Basically you connect CLOCK and SERIAL_INPUT_A to your CPU (/CLEAR and B to +ve). and you send your data one bit at a time. Most of the families of chips will have enough current to drive LEDs directly through a resistor; usually you use the shift register output to pull the LED to ground. This works well but if you don't clock the bits very fast you can see your LED pattern "ghosting".

To avoid that, you want the data to appear on all the output pins at the same time, and you need a latching one or one with output control, here's the very flexible 74LS595:

Texas datasheet

Here's a tutorial about using it from an Arduino.

## With Special Device

If you want brightness control or very many LEDs, you might use an array and a special chip such as the MAX 7219 or its almost-identical twim 7221. Datasheet.

Here you have very many fewer resistors and because the LEDs are in an array, you can drive 64 of them, and they are commonly used to drive, for example eight-digit 7-segment displays. These chips stack up, so you can use several in row to make a larger array of LEDs. (Indeed, you can buy LED arrays with these chips already in them.)

## With Special LEDs

There are LEDs which take serial inputs, known either as WS2812 or Neopixel. These take a serial interface directly, as each LED has its own chip to decode its signal.

## Special Lighting Protocols DMX-512

For architectural or theatre lighting, the standard is a simple serial protocol called DMX-512.

• "Unbuffered" shift registers ('164) without driver blanking/disable allow severe "ghosting". Commented Mar 31, 2023 at 13:41
• @greybeard Thanks for mentioning it, I've emphasised that in an edtir. Commented Mar 31, 2023 at 13:56