Code misbehaving when array is too large?

I’m doing a sort of POV display. I’ve got a giant array for the font, but if I have more than a certain number of items in the array, the program misbehaves. How can I fix this?

code:
font.h

bool font[][35] = {
  {0,1,1,1,0, 1,0,0,0,1, 0,0,0,0,1, 0,1,1,0,1, 1,0,1,0,1, 1,0,1,0,1, 0,1,1,1,0},{0,1,1,1,0, 1,0,0,0,1, 1,0,0,0,1, 1,0,0,0,1, 1,1,1,1,1, 1,0,0,0,1, 1,0,0,0,1},{1,1,1,1,0, 1,0,0,0,1, 1,0,0,0,1, 1,1,1,1,0, 1,0,0,0,1, 1,0,0,0,1, 1,1,1,1,0},{0,1,1,1,0, 1,0,0,0,1, 1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,1, 0,1,1,1,0},{1,1,1,0,0, 1,0,0,1,0, 1,0,0,0,1, 1,0,0,0,1, 1,0,0,0,1, 1,0,0,1,0, 1,1,1,0,0},{1,1,1,1,1, 1,0,0,0,0, 1,0,0,0,0, 1,1,1,1,0, 1,0,0,0,0, 1,0,0,0,0, 1,1,1,1,1},{1,1,1,1,1, 1,0,0,0,0, 1,0,0,0,0, 1,1,1,1,0, 1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0},{0,1,1,1,0, 1,0,0,0,1, 1,0,0,0,0, 1,0,1,1,1, 1,0,0,0,1, 1,0,0,0,1, 0,1,1,1,1},{1,0,0,0,1, 1,0,0,0,1, 1,0,0,0,1, 1,1,1,1,1, 1,0,0,0,1, 1,0,0,0,1, 1,0,0,0,1},{0,1,1,1,0, 0,0,1,0,0, 0,0,1,0,0, 0,0,1,0,0, 0,0,1,0,0, 0,0,1,0,0, 0,1,1,1,0},{0,0,1,1,1, 0,0,0,1,0, 0,0,0,1,0, 0,0,0,1,0, 0,0,0,1,0, 1,0,0,1,0, 0,1,1,0,0},{1,0,0,0,1, 1,0,0,1,0, 1,0,1,0,0, 1,1,0,0,0, 1,0,1,0,0, 1,0,0,1,0, 1,0,0,0,1},{1,0,0,0,0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0,1, 0,0,0,1,0, 0,0,0,0,0, 0,0,0,0,0},{0,1,1,1,1, 1,0,0,0,0, 0,1,1,1,0, 1,0,0,0,1, 0,1,1,1,0, 0,0,0,0,1, 1,1,1,1,0},
};

main:

#include <Servo.h>
#include "font.h"

Servo servo;
int colTime;
int spaceTime; //continuum


void printChar(char in){
  int i,j;

  for(i=0;i<5;i++){
    for(j=0;j<7;j++){
      digitalWrite(j+2, font[in][i+j*5]);
    }
    delay(colTime);
  }
  for(j=0;j<7;j++){
    digitalWrite(j+2, 0);
  }
  delay(spaceTime);
  
}

void track(int t){
  if(t==1){
    servo.write(52);
    colTime = 5;
    spaceTime = 2;
  }
  else if(t==2){
    servo.write(64);
    colTime = 20;
    spaceTime = 10;
  }
  else if(t==3){
    servo.write(77);
    colTime = 17;
    spaceTime = 10;
  }
}


void setup(){
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  servo.attach(14);  // attaches the servo on pin 9 to the servo object
  
  colTime = 20;
  spaceTime = 10;
  
  track(3);
}

void loop(){
  printChar(0);
  
  
}

The code should print an @ symbol but instead prints an odd sort of F. If I comment out the 2nd half of the last line in the font array, it works.

Another example: if I put “five*” where is should logically go, it prints nothing. (it apparently can’t keep track of 6 strings.)*
```
*#include <Servo.h>
#include “font.h”

Servo servo;
int colTime;
int spaceTime; //continuum

String six = “ALREADY KNOW THEYLL FIND”;
String one = “ITS THE CHILDREN”;
String two = “WHO ARE THE MASTERS”;
String three = “OF NOTICING THEIR ENVIRONMENT”;
String four = “ADULTS ONLY”;
String five = “LOOK FOR WHAT THEY”;

// - Zullwick

void printChar(char in){
  int i,j;
  if(in == ’ '){
    delay(colTime*5+spaceTime);
    return;
  }
  char ind = in - ‘A’;
  for(i=0;i<5;i++){
    for(j=0;j<7;j++){
      digitalWrite(j+2, font[ind][i+j*5]);
    }
    delay(colTime);
  }
  for(j=0;j<7;j++){
    digitalWrite(j+2, 0);
  }
  delay(spaceTime);
 
}

void track(int t){
  if(t==1){
    servo.write(52);
    colTime = 40;
    spaceTime = 45;
    //7 chars long
  }
  else if(t==2){
    servo.write(66);
    colTime = 25;
    spaceTime = 25;
    //12 chars long
  }
  else if(t==3){
    servo.write(78);
    colTime = 17;
    spaceTime = 17;
    //18 chars long
  }
  delay(250);
}

void setup(){
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  servo.attach(12);  // attaches the servo on pin 9 to the servo object 
  //track(2);
}

void loop(){
  int i;
  track(1);
  for(i=0;i<one.length();i++){
    printChar(one[i]);
  }
  track(2);
  for(i=0;i<two.length();i++){
    printChar(two[i]);
  }
  track(3);
  for(i=0;i<three.length();i++){
    printChar(three[i]);
  }
  track(1);
  for(i=0;i<four.length();i++){
    printChar(four[i]);
  }
  track(2);
  for(i=0;i<18;i++){
    printChar(“LOOK FOR WHAT THEY”[i]);
  }
  track(3);
  for(i=0;i<six.length();i++){
    printChar(six[i]);
  }
  delay(2000);
 
}*
```

You have run out of SRAM. To get around this you can store your constant data in flash memory and pull it out on an as-needed basis. See this link for how.

Sweet, thanks.