I've got an interesting problem. I built a panel of 5 8x8 led arrays to scroll text. I'm using this code, borrowed from John Boxall's Tronixstuff.com [here. I've deleted the font from the code; it exceeded the forum's size limit, but it's on the Tronixstuff page.
// based on an orginal sketch by Arduino forum member "danigom"
// http://forum.arduino.cc/index.php?action=profile;u=188950
#include <avr/pgmspace.h>
#include <LedControl.h>
const int numDevices = 5; // number of MAX7219s used
const long scrollDelay = 75; // adjust scrolling speed
unsigned long bufferLong [14] = {0};
LedControl lc=LedControl(12,11,10,numDevices);
prog_uchar scrollText[] PROGMEM ={
" THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG 1234567890 the quick brown fox jumped over the lazy dog \0"};
void setup(){
for (int x=0; x<numDevices; x++){
lc.shutdown(x,false); //The MAX72XX is in power-saving mode on startup
lc.setIntensity(x,8); // Set the brightness to default value
lc.clearDisplay(x); // and clear the display
}
}
void loop(){
scrollMessage(scrollText);
scrollFont();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FONT DELETED FROM HERE
};
void scrollFont() {
for (int counter=0x20;counter<0x80;counter++){
loadBufferLong(counter);
delay(500);
}
}
// Scroll Message
void scrollMessage(prog_uchar * messageString) {
int counter = 0;
int myChar=0;
do {
// read back a char
myChar = pgm_read_byte_near(messageString + counter);
if (myChar != 0){
loadBufferLong(myChar);
}
counter++;
}
while (myChar != 0);
}
// Load character into scroll buffer
void loadBufferLong(int ascii){
if (ascii >= 0x20 && ascii <=0x7f){
for (int a=0;a<7;a++){ // Loop 7 times for a 5x7 font
unsigned long c = pgm_read_byte_near(font5x7 + ((ascii - 0x20) * 8) + a); // Index into character table to get row data
unsigned long x = bufferLong [a*2]; // Load current scroll buffer
x = x | c; // OR the new character onto end of current
bufferLong [a*2] = x; // Store in buffer
}
byte count = pgm_read_byte_near(font5x7 +((ascii - 0x20) * 8) + 7); // Index into character table for kerning data
for (byte x=0; x<count;x++){
rotateBufferLong();
printBufferLong();
delay(scrollDelay);
}
}
}
// Rotate the buffer
void rotateBufferLong(){
for (int a=0;a<7;a++){ // Loop 7 times for a 5x7 font
unsigned long x = bufferLong [a*2]; // Get low buffer entry
byte b = bitRead(x,31); // Copy high order bit that gets lost in rotation
x = x<<1; // Rotate left one bit
bufferLong [a*2] = x; // Store new low buffer
x = bufferLong [a*2+1]; // Get high buffer entry
x = x<<1; // Rotate left one bit
bitWrite(x,0,b); // Store saved bit
bufferLong [a*2+1] = x; // Store new high buffer
}
}
// Display Buffer on LED matrix
void printBufferLong(){
for (int a=0;a<7;a++){ // Loop 7 times for a 5x7 font
unsigned long x = bufferLong [a*2+1]; // Get high buffer entry
byte y = x; // Mask off first character
lc.setRow(3,a,y); // Send row to relevent MAX7219 chip
x = bufferLong [a*2]; // Get low buffer entry
y = (x>>24); // Mask off second character
lc.setRow(2,a,y); // Send row to relevent MAX7219 chip
y = (x>>16); // Mask off third character
lc.setRow(1,a,y); // Send row to relevent MAX7219 chip
y = (x>>8); // Mask off forth character
lc.setRow(0,a,y); // Send row to relevent MAX7219 chip
}
}
Here's the thing: When I input 5 (or any number >5) as the number of devices "numDevices" in line 3, the message scrolls from right to left across the first 4 arrays (counting from the right) but the fifth array stays blank. If I input numDevices less than 5, say 4 for example, the message scrolls from right to left across the first four (or three or whatever number I use) arrays, then repeats on the last array on the left.
What am I missing here? I know all the panels are good, they're hooked together with jumpers they all light up OK, I assume my problem is in the code but I'm not seeing it.](Tutorial – Arduino and the MAX7219 LED Display Driver IC | tronixstuff.com)
Try my Parola library, link below. If you get the same problem then it is hardware, although it does look like the hardware works when you just have 4 modules defined.
If you use the library please make sure you read the documentation for the associated MAX72xx library as you may need to change the type of hardware supported.
Thanks, Marco, I'll check it out!
Marco:
I've tried the parola and Max72xx sketches with my setups (I have 5-array panels built using both generic and FC-16 led arrays) but I'm getting nothing out on the led arrays and gibberish on the serial monitor. Both my panels work with my old sketches so I'm confident of the hardware. I'm pretty sure I'm missing something on the code side.
I've got the MD_Parola, MD_MAX72Xxx and MD_KeySwitch libraries loaded and I've rebooted the IDE, and I've checked that the pinout on my setups matches the pinout in the sketches.
Can you suggest where I should look next?
Thanks!
Thanks, Marco! I've been reading through the MD_MAX72xx header file as you suggested and I've got most of the sketches to work on my FC16 arrays.
What an incredible resource you created! Much appreciated by this newbie to the Arduino club!
There is nothing special about the daft punk example. Once the libraries are set up for your hardware type all the examples should be fine. Can you run the other examples?
Check that you have disabled the change button - if you have a noisy input and no button attached then it could be changing the display quickly which may show the effect you see.
Had a little head-scratcher today while playing with the Parola sketches. I have a panel of 5 8x8 FC-16 arrays hard-wired to a nano clone. I had previously soldered the DIN, CLK and CS pins to D10, D11 and D12 so I just changed the pin definitions in the sketch to match my wiring. I couldn't get the sketches to run so, after much fiddling and messing with the arrays, rechecking, etc. I changed my wiring to D10, D11 and D13 the way Marco has it in his original sketch and now they run perfectly.
Can anybody explain to me why this is?
Hi, Marco, we cross-posted! See my post above--I've got it working great now.
Ok. Note if you are not using the hardware SPI then you need to create the object differently, as the pins need to be passed through to the library.
Hey, Marco, I've been playing with the daft punk sketch, trying to make it scroll the text messages, then run through a couple of the graphics routines, then scroll the text again, and so on. I've got three lines of text, instead of six as in the original sketch. I'm doing this by altering the switch/case portion of the sketch like this:
{
case 0: bRestart = scrollText(bRestart, msgTab[mesg]); break;
case 1: bRestart = graphicMidline2(bRestart); break;
case 2: bRestart = graphicScanner(bRestart); break;
case 3: bRestart = graphicRandom(bRestart); break;
case 4: bRestart = scrollText(bRestart, msgTab[mesg]); break;
case 5: bRestart = graphicFade(bRestart); break;
case 6: bRestart = graphicSpectrum(bRestart); break;
case 7: bRestart = graphicHeartbeat(bRestart); break;
case 8: bRestart = scrollText(bRestart, msgTab[mesg]); break;
case 9: bRestart = graphicEyes(bRestart); break;
case 10: bRestart = graphicBounceBall(bRestart); break;
case 11: bRestart = scrollText(bRestart, msgTab[mesg]); break;
case 12: bRestart = graphicArrow(bRestart); break;
case 13: bRestart = graphicScroller(bRestart); break;
case 14: bRestart = scrollText(bRestart, msgTab[mesg]); break;
case 15: bRestart = graphicWiper(bRestart); break;
case 16: bRestart = graphicInvader(bRestart); break;
default: state = 0;
}
}
It works, sort of. In case 0, it scrolls all three lines of text, but in cases 4, 8, 11 and 14 it only scrolls the first line, then moves on to the next case. Can you explain why it does that?
Thanks!
Tom
Unless you changed this part of the code
if (changeState)
{
if (state == 0) // the message display state
{
mesg++;
if (mesg >= sizeof(msgTab)/sizeof(msgTab[0]))
{
mesg = 0;
state++;
}
}
else
state++;
bRestart = true;
};
it will not work, as there is an assumption that the message display state is the case 0 state. That is when the code increments the msg variable and you get all three. Work through the logic.
You will need to change it so that is is not case 0 dependent.
Untested, but I think this sort of logic will work
static boolean bInMessages = false;
....
if (changeState)
{
if (bInMessages) // the message display state
{
mesg++;
if (mesg >= sizeof(msgTab)/sizeof(msgTab[0]))
{
mesg = 0;
bInMessages = false;
state++;
}
}
else
state++;
bRestart = true;
};
// now do whatever we do in the current state
switch(state)
{
case 0: bInMessages = true; bRestart = scrollText(bRestart, msgTab[mesg]); break;
case 1: bRestart = graphicMidline1(bRestart); break;
case 2: bRestart = graphicMidline2(bRestart); break;
case 3: bRestart = graphicScanner(bRestart); break;
case 4: bRestart = graphicRandom(bRestart); break;
case 5: bRestart = graphicFade(bRestart); break;
case 6: bRestart = graphicSpectrum(bRestart); break;
case 7: bRestart = graphicHeartbeat(bRestart); break;
case 8: bRestart = graphicHearts(bRestart); break;
case 9: bRestart = graphicEyes(bRestart); break;
case 10: bRestart = graphicBounceBall(bRestart); break;
case 11: bRestart = graphicArrow(bRestart); break;
case 12: bRestart = graphicScroller(bRestart); break;
case 13: bRestart = graphicWiper(bRestart); break;
case 14: bRestart = graphicInvader(bRestart); break;
default: state = 0;
}
}
Thanks, Marco--that worked great!
Hello Guy's,
As road_thing, I try out to drive 8 MATRIX using ledcontrol.h and the original programm (http://www.planetarduino.org/?cat=432) and didn't find out how to do it. (even if it looks trivial for the othor).
parola is mutch more complex and i would like to make it work with ledcontrol.h
the solution should be in the part below ???
void printBufferLong(){
for (int a=0;a<7;a++){ // Loop 7 times for a 5x7 font
unsigned long x = bufferLong [a2+1]; // Get high buffer entry
byte y = x; // Mask off first character
lc.setRow(3,a,y); // Send row to relevent MAX7219 chip
x = bufferLong [a2]; // Get low buffer entry
y = (x>>24); // Mask off second character
lc.setRow(2,a,y); // Send row to relevent MAX7219 chip
y = (x>>16); // Mask off third character
lc.setRow(1,a,y); // Send row to relevent MAX7219 chip
y = (x>>8); // Mask off forth character
lc.setRow(0,a,y); // Send row to relevent MAX7219 chip
But increase lc.setrow and the y value doesn t help
I know this post is to old but I ve got nothing else to do. I search everywhere without any succes.
}
parola is mutch more complex and i would like to make it work with ledcontrol.h
This is impossible as ledcontrol is too slow and does not support the primitives required by Parola.
As for the rest, I have no comment as I don't understand what you are doing. Someone else may comment.