Max7219 LED display

Hello Forum,

Working on an LED display driven by MAX7219.
All of the explanations that can be found work on seven segment
LEDs or LED matrices. The display needed is 314 LEDs in a line
that come on one at a time, stay on for five seconds after the last
LED has come on and then the whole display turns off.
The LEDS make up a pattern that is eight characters in cursive
and the effect would be as if some one were writing the characters.

The closest thing to a linear display that could be found was at

So the challenge was to take the 8x8 matrix and rearrange the

layout so that the layout was in a line. The first attempt
was to stretch out the matrix by rows

This only shows the first twenty-one lights but this pattern would be
repeated thru the first 64 lights. Then the pattern would be duplicated
for another four MAX7210 ICs to provide control for
320 lights, six more than the 314 required.
An attempt was made to make the layout more efficient resulted in

But either way, taking the matrix and stringing it out so it
will become a line seems to result in a lot of crossing
wires. (Unless someone can think of a more efficient wiring layout.)

With that done an attack was made on the code.
The simplest sketch that could be found was at
The code copied here turns on the first 21 LEDs in the
hardware pattern above marked “MAX7219 Layout for Linear
Display Row Sequence” Extending the row sequence pattern
the code would turn on the first 64 LEDs. The 65th
LED would be turned on with the code
lc.setLed(1,DP,DIG0,true); //first LED operated by the second MAX7219
At the end of the line, after the 314th LED comes on
would be a five second delay statement and then
lc.clearDisplay(0);// clear screen

Besides any advise on making the wiring layout more efficient,
the big question is: Is there a way to write the code that,
instead of wrting lc.setLed(intAddressX, rowX, columnX, boolean)
314 times, using a ‘for’ statement, something like
for (int row=0; row<8; row++)
for (int col=0; col<8; col++)
lc.setLed(0,col,row,true); // turns on LED at col, row
I am afraid my programming skills are a bit primitive so
some adult supervision in the sketch could make the
code much more economical


Allen Pitts, Dallas Texas

#include "LedControl.h" //  need the library
LedControl lc=LedControl(12,11,10,5); // 
// pin 12 is connected to the MAX7219 pin 1
// pin 11 is connected to the CLK pin 13
// pin 10 is connected to LOAD pin 12
// 5 as we are using 5 MAX7219s
void setup()
  // the zero refers to the MAX7219 number, it is zero for 1 chip
  lc.shutdown(5,false);// turn off power saving, enables display
  lc.setIntensity(5,8);// sets brightness (0~15 possible values)
  lc.clearDisplay(5);// clear screen
void loop()

  lc.setLed(0,DP,DIG0,true); // turns on LED 0.0
  lc.setLed(0,A,DIG0,true); // turns on LED 0.1
  lc.setLed(0,B,DIG0,true); // turns on LED 0.2
  lc.setLed(0,C,DIG0,true); // turns on LED 0.3
  lc.setLed(0,C,DIG0,true); // turns on LED 0.4
  lc.setLed(0,D,DIG0,true); // turns on LED 0.5
  lc.setLed(0,E,DIG0,true); // turns on LED 0.6
  lc.setLed(0,F,DIG0,true); // turns on LED 0.7
  lc.setLed(0,G,DIG0,true); // turns on LED 0.8
  lc.setLed(0,DP,DIG1,true); // turns on LED 1.0
  lc.setLed(0,A,DIG1,true); // turns on LED 1.1
  lc.setLed(0,B,DIG1,true); // turns on LED 1.2
  lc.setLed(0,C,DIG1,true); // turns on LED 1.3
  lc.setLed(0,C,DIG1,true); // turns on LED 1.4
  lc.setLed(0,D,DIG1,true); // turns on LED 1.5
  lc.setLed(0,E,DIG1,true); // turns on LED 1.6
  lc.setLed(0,F,DIG1,true); // turns on LED 1.7
  lc.setLed(0,G,DIG1,true); // turns on LED 1.8
  lc.setLed(0,DP,DIG1,true); // turns on LED 2.0
  lc.setLed(0,A,DIG1,true); // turns on LED 2.1
  lc.setLed(0,B,DIG1,true); // turns on LED 2.2
  lc.setLed(0,C,DIG1,true); // turns on LED 2.3
  lc.setLed(0,C,DIG1,true); // turns on LED 2.4

Hi Allen,

I think wiring this up is going to be a bit of a nightmare.

Have you considered using ws2812 leds? They are RGB, which you don't need but would enable many creative possibilities, but the big advantage would be the need for only 3 wires, daisy-chained along the entire line.


Big disadvantage - waaaay more power needed, up to 60mA per unit.
With 5 MAX7219, for 320 LEDs, only 8 LEDs are on at any one time, so total current is like 800mA total with 20mA/LED.
Sure, the wiring might be a pain in the butt to support your layout, but it will be pretty simple to write to the registers in the MAX7219s to control the LEDs.
Just have an array of 40 bytes *8 x 40 = 320 bits) to represent the state of the individual LEDs, send out refresh data when one changes.
I make this little adapter board even, wire each LED with a pair of wires (30 AWG wirewrap wire, make a bunch up while watching TV) ending in 2 male pins, and plug in, daisy chain 5 together.

Bob, the ws2812 could consume far more current, but they don't have to. If you only use one colour, eg. just red, and a brightness setting of 32 which is equivalent to 1/8 multiplex, it would use around the same current and get around the same brightness. But if you can afford a psu with more guts, you can go way brighter than max7219 in rainbow colours.