1
\$\begingroup\$

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?

\$\endgroup\$
11
  • 1
    \$\begingroup\$ Essentially your MCU will send the data serially. There are endless ways to do it, not least of which is a basic shift register. \$\endgroup\$
    – jonathanjo
    Commented Mar 31, 2023 at 10:52
  • \$\begingroup\$ A LED strip with hundreds of LEDs controlled by one data wire. How many LEDs you need? \$\endgroup\$
    – Justme
    Commented Mar 31, 2023 at 10:52
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Justme
    Commented Mar 31, 2023 at 10:59
  • 3
    \$\begingroup\$ 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. \$\endgroup\$
    – jonathanjo
    Commented Mar 31, 2023 at 11:13
  • 3
    \$\begingroup\$ If your LEDs all have the same forward voltage you could look into Charlieplexing nl.wikipedia.org/wiki/Charlieplexing \$\endgroup\$
    – Bart
    Commented Mar 31, 2023 at 11:47

1 Answer 1

2
\$\begingroup\$

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) enter image description here

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:

enter image description here

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.)

enter image description here

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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