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
http://www.wayoda.org/arduino/ledcontro … onstructor
http://www.allenpitts.com/electronics/M … layout.gif
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
http://www.allenpitts.com/electronics/M … ut_row.gifThis 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.
http://www.allenpitts.com/electronics/M … ut_col.gifBut 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
http://www.planetarduino.org/?cat=432
The code copied here below turns on the first 21 LEDs in the
hardware pattern above marked "MAX7219 Layout for Linear
Display Row Sequence" above. Extending the row sequence pattern in
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 writing lc.setLed(intAddressX, rowX, columnX, boolean)
314 times, uses 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
delay(25);
}
}
I am afraid my programming skills are a bit primitive so
some adult supervision in the sketch could make the
code much more economical
Thanks.
Allen in Dallas
#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 MAX7219's
void setup()
{
// the zero refers to the MAX7219 number, it is zero for 1 chip
//and 4 (I think) for 5 chips
lc.shutdown(4,false);// turn off power saving, enables display
lc.setIntensity(4,8);// sets brightness (0~15 possible values)
lc.clearDisplay(4);// clear screen
}
void loop()
{
lc.setLed(0,DP,DIG0,true); // turns on LED 0.0
delay(25);
lc.setLed(0,A,DIG0,true); // turns on LED 0.1
delay(25);
lc.setLed(0,B,DIG0,true); // turns on LED 0.2
delay(25);
lc.setLed(0,C,DIG0,true); // turns on LED 0.3
delay(25);
lc.setLed(0,C,DIG0,true); // turns on LED 0.4
delay(25);
lc.setLed(0,D,DIG0,true); // turns on LED 0.5
delay(25);
lc.setLed(0,E,DIG0,true); // turns on LED 0.6
delay(25);
lc.setLed(0,F,DIG0,true); // turns on LED 0.7
delay(25);
lc.setLed(0,G,DIG0,true); // turns on LED 0.8
delay(25);
lc.setLed(0,DP,DIG1,true); // turns on LED 1.0
delay(25);
lc.setLed(0,A,DIG1,true); // turns on LED 1.1
delay(25);
lc.setLed(0,B,DIG1,true); // turns on LED 1.2
delay(25);
lc.setLed(0,C,DIG1,true); // turns on LED 1.3
delay(25);
lc.setLed(0,C,DIG1,true); // turns on LED 1.4
delay(25);
lc.setLed(0,D,DIG1,true); // turns on LED 1.5
delay(25);
lc.setLed(0,E,DIG1,true); // turns on LED 1.6
delay(25);
lc.setLed(0,F,DIG1,true); // turns on LED 1.7
delay(25);
lc.setLed(0,G,DIG1,true); // turns on LED 1.8
delay(25);
lc.setLed(0,DP,DIG1,true); // turns on LED 2.0
delay(25);
lc.setLed(0,A,DIG1,true); // turns on LED 2.1
delay(25);
lc.setLed(0,B,DIG1,true); // turns on LED 2.2
delay(25);
lc.setLed(0,C,DIG1,true); // turns on LED 2.3
delay(25);
lc.setLed(0,C,DIG1,true); // turns on LED 2.4
delay(25);
}