Go Down

Topic: using Max7219-Library to code scrolling words on 5x7 LED matrix (Read 1 time) previous topic - next topic

vigman

I've been trying to create an LED display board with many 5x7 matrix. I found the best way to do this is with an Arduino and max7219 chips. I've tried different libraries and copied examples of code to get an idea how to program but I'm having trouble scrolling. I found many tutorials that didn't include cascading maxims, or used 7-seg, or 8x8,  or an accessible way to download the complementary library. The farthest I've come was scrolling across one 5x7 display with tedious coding. I dont fully understand how to use strings and char.
The max7219-library sparked my interest because the web page says

"•the MAX7219-Library is another available library that supports cascaded MAX7219's and some basic matrix functions(e.g shiftleft, shiftright, flip, rotate, raise, lower). "

Are these functions easy to use or do they involve the same programming procedures as LedControl and Matrix Library?

I would show my code so far but it's uninteresting and elementary.

Thank you to anyone who can respond!

CrossRoads

I made a 32x8 display recently using a MAX7219 for each of 4 matrices.
This took me a while to organize and figure how to code, but I made it work like this.
I had all my font information stored in PROGMEM, 5 bytes per character. Each byte represented 1 column of the font,
for example:
01110
10001
10001
11111
10001
10001
10001
10001

79997
F000F

so for the letter A I had

byte fontArray[ ] = {
:
:
0x7f, 0x79, 0x79, 0x79, 0x7F, // A
:
:
}
(and somehow PROGMEM gets added in there)
Every 5 bytes is a new character

I have a large displayArray, about 1000 bytes.
I receive data from the serial port, looked up the bytes for the character received, and add that to the end of displayArray

switch(incomingByte){
:
:
case "a":
displayArray[endPointer] = fontArray[50];
displayArray[endPointer+1] = fontArray[51];
displayArray[endPointer+2] = fontArray[52];
displayArray[endPointer+3] = fontArray[53];
displayArray[endPointer+4] = fontArray[54];
displayArray[endPointer] = 0; // inter character spacing, interword spacing is different
endpointer = endpointer+6;
break;
:
:
}

Then every 50mS, I slide a messagePointer over 1 and read the displayArray[] data and send 32 bytes to the MAX7219s
if (elapsedTime >=50mS){
messagePointer = messagePointer +1;

// this part is too simplistic, as you need to send a register # and the data for that register.
// I actually ended up with ssPin for each device, and did a smaller 8 byte loop for each device to keep it simple
// this is just to give the idea behind it

digitalWrite(ssPin, LOW);
for (x=messagePointer; x<messagePointer+32; x=x+1){
SPI.transfer(displayArray[ x ] );
}
digitalWrite(ssPin, HIGH);
}

Have to add some checks to make sure you don't add more data then you have space for, wrap the messagePointer back to the beginning once reach the end, etc.

I also added a command to store the message in EEPROM so it's there after a startup.
Next time I mess with it, I plan to store the # of the character in EEPROM (so up to 255 characters can be had), and instead of a big 1000 byte array in SRAM, just have an array that's 5-6 characters long and tack on characters to the end: get the character # from EEPROM, look up its 5 bytes in fontArray, and add those bytes to the end of displayArray after the data gets sent to the MAX7219s. Then the message can be the size of EEPROM!
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up