Scrolling message 8X8 LED array - Max7221?

Okay, I have built this project ( Arduino Playground - HomePage ) several times to display characters using direct drive fro the Arduino board. Although I've tried this several times with my R/G LED array, I simply cannot get it to work properly. I only receive some very rapid flashing of all the LEDs in various brightness. With that said, I do believe that it may be drawing too much current for a proper build anyhow....

So, I bought a couple of Max7221 ICs as they seem to be the choice for this type of project, however I cannot locate my original site for building/programming that O bought the 7221 for.....

Would anyone out there be able to point me in the direction of some good instructions where I could create a scrolling message on my Arduino (with or w/o the max7221). One color is fine as I know the pin arrangement of the bi-color 8x8 LED array. here is a YouTube that makes it look simple.... ( Arduino 8x8 LED Matrix Direct drive - YouTube ) For some reason i cannot get this direct drive method to work!

Any help/code/instructions would be helpful. :slight_smile:

If no one has posted a better example, I will post something I did with a 7219 (pin compatible with 7221) that scrolls a message later today in about six hours if I can figure out how to post a video to YouTube.

I wrote some code a while back, I will see if I can find it, the message to be scrolled was stored on an array, 8 x 80 or whatever.
During setup, some initial 8 bytes was sent to the MAX7221 via 8 SPI commands in no-decode mode.
Then every 200mS, or whatever scroll speed you wanted, the location pointer into the array would be incremented by 1 and the 8 bytes from there on would be sent to the MAX7221. 200mS later, the pointer would again be moved over 1 and the data sent out again.
If the pointer was at the end, then bytes from the beginning would be used to wrap the message around. (example 97,98,99,0,1,2,3,4).

I would love to see what you have already done. Kind of new to the Arduino and learning a lot as I go along.

I have been searching for about a week and cannot find anything else out there.

Can you either post or send to my email.... arduino@alich.com

Cheers, and thank you in advance!
Dan

This was my first arduino project:

OK, here is my text scroller, no schematic but basically it is simple: Hook up the first MAX7219 to the pins indicated in the software, daisy chain them, despike them, give them a reasonable value resistor, hook them up to the Matrices after you determine the correct matrix pins via their datasheet. The resistors chosen are 33K. The scrolling is a little choppy, but readable. Not really sure why. Code is attached.

ArduinoPlus6MAX7219s.ino.txt (10.4 KB)

Very nice, I'll have to play with this. Not sure on the build, but I'll do some research.

Dan

Attached is code I used to test scrolling messages on a pair of MAX7219 chips wired as a 16x8 matrix.

ScrollTest2.ino (13.3 KB)

Nice work Riva.

const int DIN = 12;            //DataIn pin (18)
const int CLK = 11;            //Clock pin (17)
const int LOAD = 10;           //Load pin (16)

Why not use SPI for these transfers?

Thank you Riva. Looks great. I do some research on how to hook up the array to the chip and see what happens.

I have a 7221 and from what I've been reading, they are very similar in function and seem to be nearly interchangeable.

I think this is the code I was looking for. Thanks again!

Crossroads.... SPI? I guess you just went over this newbies head again. :slight_smile: So much to learn!

CrossRoads:
Nice work Riva.

const int DIN = 12;            //DataIn pin (18)

const int CLK = 11;            //Clock pin (17)
const int LOAD = 10;           //Load pin (16)




Why not use SPI for these transfers?

The MAX7219 library (based on LedControl libray but butchered to reduce size) was written to allow the defining of the pins and bitbangs so I just left it at that. The project originally ran on an ATMega8 and only had 68 bytes program memory free so probably would not have taken the SPI library. I have since de-soldered the 8 and replaced with a 328 to give more memory to add more functions but did not bother to change it.

This is a dup of another post because my crap code is on this thread too.

The flaw in the design where there is some jitter in the display is a software problem on my side, not the LED library or hardware. What this software does is scan each row by advancing the current bit being displayed on the current character in the string until it gets to the end of that character (by length lookup) and then advancing to the next character. After each row it restores the position and advances the row until it gets to row 8. At the end of writing the rows, the software restores the position and advances by one bit (column) to achieve the scrolling effect. It has to know the correct current character to look up the current character length. Even though the software it restores the start bit position and character in string position it does not restore the current character correctly for length lookup, it uses whatever character was displayed (or partially displayed) last. This causes the counter not to advance a lot of the time and the jitter. If you are using my software for scrolling purposes, fix it with this change. Add the one line indicated.

    curcharix = curcharixsave2;
    curcharbit = curcharbitsave2;
  
    // advance the current character bit of current character

to

    curcharix = curcharixsave2;
    curcharbit = curcharbitsave2;
  
    curchar = msg[curcharix];
  
    // advance the current character bit of current character

Sorry for anyone that was inconvenienced by this bug. I actually totally rewrote the part of the code that writes to the MAX7219s and eliminated the LEDLibrary and this bug persisted which led me to the obvious conclusion that my code sucked somewhere. At least now I know how the MAX7219 works on a register level, though. The new version can scroll the display so fast it is not readable without a decent delay.

Attached code has been updated.

1 Like

Hi JoeN,

I have been playing around with some Max 7219's and scrolling text code and would like to try out your code posted here.I love the AC / DC lyrics as the message…Angus would be proud of you 8) Just a questions if I may:

So to scroll text across more than one 8 x 8 matrix just daisy chain the 7219'S with each 7219 connected to it's own matrix

Thanks for sharing this and keep Rockin' brother 8)

Pedro.

Pedro147:
Hi JoeN,

I have been playing around with some Max 7219's and scrolling text code and would like to try out your code posted here.I love the AC / DC lyrics as the message…Angus would be proud of you 8) Just a questions if I may:

So to scroll text across more than one 8 x 8 matrix just daisy chain the 7219'S with each 7219 connected to it's own matrix

Thanks for sharing this and keep Rockin' brother 8)

Pedro.

So sorry, I never got this question. I am going to have to use the 'replies' feature more.

Yes, that is exactly what you do. The 7219's are just shift registers to the microcontroller. The library is just shifting in data. Any "extra" data just falls off the "left" end. I am using 6 displays and 6 7219 driver chips. Providing more data than displays/7219 driver chips doesn't hurt anything, it is just not efficient. When you have more than six displays you will have to modify the following line to make it work:

for (i=5;i>=0;i--) // Loop through our 8 displays

Note I say 8 displays, it is actually 6, I think I intended it to be 8 in the beginning.

Thanks for getting back to me JoeN. Yes I used your code to scroll across two matrices... very nice thanks. I do prefer scrolling code like yours, where you just type in the text you wish to scroll and it is accessed from a font file within the code rather than entering an array into the actual loop for every char (tiresome 8) )

Thanks again and happy soldering / coding Pedro.

Well I was using this code to scroll 3 matrix’s and at first it scrolled the wrong way so I changed lc.setRow(i, j, outputbyte); to lc.setColumn(i, j, outputbyte); after that it works correctly except the scrolling is slow… so I found out in the LEDControl Documentation that setRow is about 8x faster than setColumn function

So for anyone with this issue its a fairly simple fix… rather than fix your row/column wiring just rotate all your displays clockwise, because as far as I can tell it cant be sped up in software… also in my case and probably most people with this issue you will need to change the order it writes the rows in otherwise the letters are flipped horizontally

so I changed the line

for (k=7;k>=0;k‚Äď) // Copy over data for 8 columns to current row and send it to current display

to

for (k=0;k<=7;k++) // Copy over data for 8 columns to current row and send it to current display

also to make it so the code auto adjusts for the number of matrix’s you have change

for (i=5;i>=0;i‚Äď) // Loop through our 8 displays

to

for (i=(lc.getDeviceCount()-1);i>=0;i‚Äď) // Loop through our displays

and last but not least replace the setup function with this one…

void setup()
{
for (int i = 0; i <= lc.getDeviceCount();i++) {
lc.shutdown(i,false);// turn off power saving, enables display
lc.setIntensity(i,10);// sets brightness (0~15 possible values)
lc.clearDisplay(i);// clear screen
}
}

I think the problem was that your matricies are not the same architecture as mine. LED matrix displays can either be column-anode, row-cathode, or column-cathode, row-anode, and though both are supported by the MAX7219/21, obviously it affects the way it works. Anyway, I am happy to hear that someone else had a successful project.

Finally figured it all out… so for anyone that has wired up their matrices like LedControl expects(or change the library code like i did) to get this sketch working all you need to change is the following line to flip the font.

for (k=7;k>=0;k‚Äď) // Copy over data for 8 columns to current row and send it to current display

to

for (k=0;k<=7;k++) // Copy over data for 8 columns to current row and send it to current display

since my columns where backwards(setLed(0,0,0,1) would light up column 7 not 0)

i copied LedControl library and in LedControl.cpp changed

val=B00000001 << column;

to

val=B10000000 >> column;

so that most peoples code for LedControl will work correctly without modification.

Now all I need to do is implement more functions to display the current time etc and im done lol

Big thanks to the author of this code… C math is not my strong suit lol and I couldn’t get scrolling to work for the life of me.

Hi Guys,

I am missing something in the wiring, I think. I have chained three 7219's , but each it acting as the first position. How does the LOAD number get set for each position?

I see the line:
for (i=(lc.getDeviceCount()-1);i>=0;i--)
should set which position should be addressed, but how does the wiring feed back which position is being lit?

fran52:
Hi Guys,

I am missing something in the wiring, I think. I have chained three 7219's , but each it acting as the first position. How does the LOAD number get set for each position?

I see the line:
for (i=(lc.getDeviceCount()-1);i>=0;i--)
should set which position should be addressed, but how does the wiring feed back which position is being lit?

If each is acting as the same position then you have bussed your serial line to each chips DIN (pin 1), which is what you want to do with the load and clock lines (pin 12, 13). But you have to daisy chain the serial data. From the Atmega you wire the serial out (you choose the pin) to the DIN (pin 1) of the first MAX7219 chip. From the first MAX7219 chip you wire the DOUT (pin 24) to the DIN (pin 1 again) of the next MAX7219 chip, and do this all the way down the chain. I have chained 24 chips this way successfully.