lol Shield problem.. Very odd..

Hi all. Just writing a simple frame display program for the lol shield. “I love you” to demonstrate how to get the different frames to come up on the screen and then my students can have a go at programing their own messages. Trouble is when I include the 3rd frame the arduino completely freezes and nothing happens. I really can’t see how adding one more frame could cause a problem? If you have an lol shield please upload the code and see if it is working for you. Should work without the third frame then try to add it and if it is working for you. completely lost as to why it’s not working.

Regards Chris

#include <Charliplexing.h> //Imports the library, which needs to be initialized in setup.
int x = 0;
int y = 0;
int t = 0;
int frame=1;
int frame1[]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,1,1,1,1,1,0,0,0,0,0,
               0,0,0,0,0,0,1,0,0,0,0,0,0,0,
               0,0,0,0,0,0,1,0,0,0,0,0,0,0,
               0,0,0,0,0,0,1,0,0,0,0,0,0,0,
               0,0,0,0,0,0,1,0,0,0,0,0,0,0,
               0,0,0,0,0,0,1,0,0,0,0,0,0,0,
               0,0,0,0,1,1,1,1,1,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0  };
               
int frame2[]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,1,1,0,1,1,0,0,0,0,0,
               0,0,0,1,0,0,1,0,0,1,0,0,0,0,
               0,0,0,1,0,0,0,0,0,1,0,0,0,0,
               0,0,0,1,0,0,0,0,0,1,0,0,0,0,
               0,0,0,0,1,0,0,0,1,0,0,0,0,0,
               0,0,0,0,0,1,0,1,0,0,0,0,0,0,
               0,0,0,0,0,0,1,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0  };
               
int frame3[]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,1,0,0,0,1,0,0,0,0,0,
               0,0,0,0,1,0,0,0,1,0,0,0,0,0,
               0,0,0,0,1,0,0,0,1,0,0,0,0,0,
               0,0,0,0,1,0,0,0,1,0,0,0,0,0,
               0,0,0,0,1,0,0,0,1,0,0,0,0,0,
               0,0,0,0,1,0,0,0,1,0,0,0,0,0,
               0,0,0,0,0,1,1,1,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0  };
               
int frame4[]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0,
               0,0,0,0,0,0,0,0,0,0,0,0,0,0  };
void setup() {
  Serial.begin(9600);
  // put your setup code here, to run once:
LedSign::Init();  //Initializes the screen


}
void loop() {
Serial.print("Frame ");
Serial.println(frame);
if (frame==1){ 
LedSign::Set(x, y, frame1[t]);
}
if (frame==2){ 
LedSign::Set(x, y, frame2[t]);
}
//if (frame==3){ 
//LedSign::Set(x, y, frame3[t]);
//}


x++;

if (x == 14)
    {
      x = 0;
      y++;
    }
    
if (y == 9){
    y = 0;
    }
t++;
if (t == 126){
      t = 0;
      delay(1000);
      LedSign::Clear(0);
      frame++;
      }
if (frame==5){
    frame = 1;}
}

maybe running out of RAM
change the int arrays to byte?

I would say an array of booleans, but I read from here (so who knows) that even an array of booleans (bits, on/off) are defined as a byte at compile time?...

if that's untrue, an array of booleans would save you heaps of memory.

Boolean won't save any more than using byte - it's stored as eight bits. Try using byte as suggested but also look at using the progmem directive to store your frame data in flash instead of RAM.

or better yet
there are 8 bits in a byte
so put 8 switches into each byte, then decode it as needed

Hmm.. I don't think memory is a problem.. Binary sketch size: 7,958 bytes (of a 32,256 byte maximum)
Also.. when I don't include the frame3 it is still in memory and the program works.. hmm..

cgozzard:
Hmm.. I don't think memory is a problem.. Binary sketch size: 7,958 bytes (of a 32,256 byte maximum)
Also.. when I don't include the frame3 it is still in memory and the program works.. hmm..

Common misconception. You have plenty of flash left, but an arduino has very little RAM - 2K for the UNO. Those arrays are consuming a great deal of it.

Right! Get you!..

Boolean array did the job! So simple!... thanks guys, I guess I'm just as much a student as I am a teacher...

Do be aware though that you've only halved your memory consumption. As soon as your students try something like "I love you, Desdemona!", you'll be back to the same issue. Progmem is an easy way to solve this, though if you're prepared to do the bit twiddling that was suggested, you can compress it much further at the expense of readability for your students. Of course, you might use the space problem as an intro to bit operations for them.

or some way of hacking it to actually allow a bit to be a 'bit'

I've even heard of people trying to find random seeds that fit their bit string.. don't think I will go that far. Ok guys. I will look into compressing it further. Interesting ideas.. thanks for everyone's help and guidance.