Weird things happening with LED matrix

So im programming a Rainbowduino with an RGB LED matrix on it, and i wrote a program that scrolls a char array accross. Like a any generic LED board does. all the variable letters look kinda like
char* a[8]={
"00111100",
"01111110",
"01100110",
"01100110",
"01111110",
"01111110",
"01100110",
"01100110"};
And add(char* in[8]) just keeps adding on the lines to 8 strings I have set up(one for each line, named line0,line1...).
Here is the important stuff:

char output[]="abcdefghijklmnop";
//in setup, adds each letter to the end of each line
for(count=0;count<sizeof(output)-1;count++){
   switch(output[count]){
    case 'a':add(a);break; 
    case 'b':add(b);break;
    case 'c':add(c);break;
    case 'd':add(d);break;
    case 'e':add(e);break;
    case 'f':add(f);break;
    case 'g':add(g);break;
    case 'h':add(h);break;
    case 'i':add(i);break;
    case 'j':add(j);break;
    case 'k':add(k);break;
    case 'l':add(l);break;
    case 'm':add(m);break;
    case 'n':add(n);break;
    case 'o':add(o);break;
    case 'p':add(p);break;
    case 'q':add(q);break;
    case 'r':add(r);break;
    case 's':add(s);break;
    case 't':add(t);break;
    case 'u':add(u);break;
    case 'v':add(v);break;
    case 'w':add(w);break;
    case 'x':add(x);break;
    case 'y':add(y);break;
    case 'z':add(z);break;
    case ' ':add(space);break;
    case '!':add(excl);break;
    case '\'':add(apos);break;
    case '?':add(quest);break;
  }
 }
//in loop
for(int row=0;row<line2.length();row++){
    for(int xx=0;xx<8;xx++){
      char zero=line0[xx+row];
      char one=line1[xx+row];
      char two=line2[xx+row];
      char three=line3[xx+row];
      char four=line4[xx+row];
      char five=line5[xx+row];
      char six=line6[xx+row];
      char seven=line7[xx+row];
       if(zero=='1')
         Rb.setPixelXY(0,xx,0,0,255);
       if(one=='1')
         Rb.setPixelXY(1,xx,0,0,255);
       if(two=='1')
         Rb.setPixelXY(2,xx,0,0,255);
       if(three=='1')
         Rb.setPixelXY(3,xx,0,0,255);
       if(four=='1')
         Rb.setPixelXY(4,xx,0,0,255);
       if(five=='1')
         Rb.setPixelXY(5,xx,0,0,255);
       if(six=='1')
         Rb.setPixelXY(6,xx,0,0,255);
       if(seven=='1')
         Rb.setPixelXY(7,xx,0,0,255);
    }
    delay(100);
    Rb.blankDisplay();
  }

Except weird things happen when I change output, if output's length is 8 or less, it works fine. If the length is greater than 8, the first 7 come out fine, then random lines will stop lighting up until it reaches the 18th letter, which will never light up. If the length is 21 or greater, the entire display will do nothing.
A text file with the full code is provided. Thanks to any and all who try to help!

code.txt (5.89 KB)

Except weird things happen when I change output, if output's length is 8 or less, it works fine.

How much free memory do you have when output's length is 8? 10? 12?

Strings use a LOT of memory. You have 8 of them. You may be running out of memory when output is longer than 8.

"Binary sketch size: 6,170 bytes (of a 30,720 byte maximum)"
is what appears when it compiles in its current state. If it comes to it, i could always work with making the big string into a bunch that are of length 8 but I'm really curious as to why this is happening, and to learn how to fix it.

After doing some debugging, I learned at the longer output strings, line0 and line5 are different lengths. But all the variable letters have the same length for 0 and 5(same length for each row).
EDIT: more debugging... the more cases I comment out, the farther it goes without messing up.
EDIT: its the add() method in the case statements. If I comment those out, it's fine, even if I never reach a certain add() statement. ex. output'"hello world how are you" and i comment out the p,q,r,s,t,u,a,b it works better.

Joshie196:
"Binary sketch size: 6,170 bytes (of a 30,720 byte maximum)"
is what appears when it compiles in its current state. If it comes to it, i could always work with making the big string into a bunch that are of length 8 but I'm really curious as to why this is happening, and to learn how to fix it.

The sketch size indicates how much of the flash memory is required to store the program. It gives no indication of the amount of SRAM the sketch will require when running. On an Arduino Uno, there is only 2KB of SRAM available. As you are using the String class, each time you do String concatenation, a new copy of the String is created, and the previous one destroyed. This leads to memory fragmentation, and you run out of enough free memory for your sketch to continue.

Hi Joshie196,

I'm not familiar with the Rainbowduino language but I have done similar thing for the MAX7219.
I would suggest moving the font to PROGMEM if your running out of RAM.
I have attached a sample program I wrote to scroll a message across a 16x8 LED matrix. All you should need to do is alter the printBufferLong() routine to suit your requirements.
To rotate I have a Long (32 bits) array and OR each 8 bit font character into bits 0-7 and then rotate the long 1 bit left, I then display bits 16-23 (repeat 8 times). I us a long because the final font will be 10x7.

EDIT:
Here is the printBufferLong() routine modified to work with Rainbowduino

// Display Buffer on LED matrix
void printBufferLong(){
    long rgb = 0L;
    for (int a=0;a<7;a++){                      // Loop 7 times for a 5x7 font
        unsigned long x = bufferLong [a];       // Get buffer entry
        int y = (x>>8) & 0xff;                  // Mask off left hand character
        for(int xx=0;xx<8;xx++){
            if (y & 0x01) {
                rgb = 0xFF0000;
            }
            else{
                rgb = 0L;
            }
            Rb.setPixelXY(xx,a,rgb);       //use 24-bit color value
            y = y>>1;
        }
    }
}

ScrollTest2.ino (13.3 KB)

Riva, thanks a bunch for the code, ill definitely be dissecting it and applying it to my project.

I have since asked a mate to test the code on his Rainbow and can confirm it works. I could almost be tempted to buy one myself for messing around with.