Restricted characters of scrolling text

I have a problem with the code that I use for my 8x8x5 LED matrix based on 5 MAX7221.The problem is that I can not put into written more than a certain number of characters, and it’s not an exact number, I think.How can I make sure that I can write something longer?

I hope in your help

Thanks
Code Part1

//We always have to include the library
//File created for ArtFunk Props
#include "LedControl.h"
#include <Button.h>

// Change these pin numbers as neccessary
char Pin_dataIn = 10; // data in pin
char Pin_clk = 7; // clk pin
char Pin_load = 8; // load pin
char numOfMatrices = 5; // increment this for each 7219 you've got connected.  I imagine this will be 5.
int brightness = 8; // set the brightness of the LEDs.  Use a value between 0 - 15
char screen[40];
char screenSize = 40;

char textBuffer[3][100];
char textBufferSize[3] = {100,51,66};

int pointer = 0;
long nextFrameTime = 0;
int effectType = 0;
int framePointer = 0;

// init led control object
LedControl lc = LedControl(Pin_dataIn,Pin_clk,Pin_load,numOfMatrices);
Button button = Button(4, HIGH);

/* we always wait a bit between updates of the display */
unsigned int delayTime=40;

void setup() {
  
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  for(int index=0;index<lc.getDeviceCount(); index++) {
    lc.shutdown(index,false);
    /* Set the brightness to a medium values */
    lc.setIntensity(index,brightness);
    /* and clear the display */
    lc.clearDisplay(index);
      
  }
  
  randomSeed(analogRead(0));
  button.setHoldDelay(3000);
  loadTextBuffers();
}



void loop() { 
  
  button.listen();
  
  if(button.onRelease()) {
    effectType++;
    
    if(effectType > 10) {
      effectType = 0;  
    }
    
    pointer = 0;
    framePointer = 0;
  }
  
  long current = millis();
  
  if(current > nextFrameTime) {
  
   nextFrameTime = current + delayTime; 
    
   switch(effectType) {
    case 4:
      effectThinLine();
      break;
    case 1:
       effectRandomPixels();
      break;
    case 2:
      effectScanner();
      break;  
    case 3:
      effectBlinkingEyes();
       break;
    case 5:
      effectTextScroll(0);
      break;
    case 0:
      effectTextScroll(1);
      break; 
    case 6:
      effectTextScroll(2);
      break;
    case 7:
      effectHearts();
      break;    
    case 8:
      effectECG();
      break;  
    case 9:
      effectScannerHorizontal();
      break;
    default:
      effectBlank();
      break;
  }

   display();
   
  }
   
}

void display() {
  
  unsigned char matrixID = 0;
  // screen now holds the updated values
  // write to the matrix
  for(unsigned char i = 0; i < numOfMatrices; i++) { 
    for(int j = 0; j < 8; j++) {
      
      int k = j;
       k += 1;
      if(k > 7) {
        k = 0;
      }
      
      char matrixID = 4 - i;
      //matrixID = 0;
      char bufferData = screen[((7-k)+(i*8))];
      char rowData = (bufferData >> 1) | (bufferData << 7);
     
      lc.setRow(matrixID,j,rowData);
    } 
  }
  
  /*
  for(unsigned char i = 0; i < screenSize; i++) {
   matrixID = floor(i/8);
    lc.setColumn(matrixID,i,screen[i]);
  }
  
   for(unsigned char i = 0; i < numOfMatrices; i++) { 
    for(unsigned char j = 0; j < 8; j++) {
      char matrixID = 4 - i;
      //matrixID = 0;
      lc.setColumn(matrixID,j,screen[(j+(i*8))]);
    }  
  }
  */
}

void scrollFromRight(int bufferNum) {
int offset = screenSize - pointer;
  for(unsigned char i = 0; i < screenSize; i++) {  
    screen[i] = getBufferData(bufferNum, i-offset);     
  }  
}

void scrollFromLeft(int bufferNum) {
int offset = (0-textBufferSize[bufferNum]) + pointer;
  for(unsigned char i = 0; i < screenSize; i++) {  
    screen[i] = getBufferData(bufferNum, i-offset);   
  }  
}

void staticCenter(int bufferNum) {
  int offset = round((screenSize - textBufferSize[bufferNum]) / 2);	
   for(unsigned char i = 0; i < screenSize; i++) {
    screen[i] = getBufferData(bufferNum, i-offset); 		
   }

}


char getBufferData(int bufferNum, int pos) {
    char tmp;
    if((pos >= 0) && ((pos) < textBufferSize[bufferNum])) {
      return textBuffer[bufferNum][pos];
    } else {
      return B00000000;
    }
}

void effectThinLine() {

  for(int i = 0; i < 40; i++) {
    screen[i] = B00011000;
  }
}  


void effectRandomPixels() {
  for(int i = 0; i < 40; i++) {
    screen[i] = random(256);
  }
}

void effectScanner() {
  for(int i = 0; i < 40; i++) {
    screen[i] = B00000000;
  }
  
  
  int tmpPointer = framePointer;
  
  if(framePointer > 37) {
    tmpPointer = 37 - (framePointer - 37);
  }
  
  for(int i = tmpPointer; i < (tmpPointer+3); i++) {
    screen[i] = B11111111;  
  }
  
  framePointer++;
  
  if(framePointer > 73) {
    framePointer = 0;
  }
  
}

void effectScannerHorizontal() {
  
   int tmpPointer = framePointer;
    
    if(framePointer > 6) {
        tmpPointer = 6 - (framePointer - 6);
     }
  
  for(int i = 0; i < 40; i++) {
    screen[i] = B10000000 >> (tmpPointer + 1);
  }
  
  display();
  delay(50);
  
  framePointer++;
  
  if(framePointer > 11) {
    framePointer = 0;
  }
  
}

void effectBlank() {
  for(int i = 0; i < 40; i++) {
    screen[i] = B00000000;
  }
}

void effectTextScroll(char bufferNum) {
   pointer += 1;
   
   if(pointer > (textBufferSize[bufferNum] + screenSize)) {
     pointer = 0;  
   }
   
   scrollFromRight(bufferNum);
}

void effectBlinkingEyes() {
  if(random(50) == 0) {

        
screen[0] =  B00000000;
screen[1] =  B00000000;
screen[2] =  B00000000;
screen[3] =  B00000000;
screen[4] =  B00000000;
screen[5] =  B00000000;
screen[6] =  B00000000;
screen[7] =  B00000000;
screen[8] =  B00011000;
screen[9] =  B00011000;
screen[10] = B00011000;
screen[11] = B00011000;
screen[12] = B00011000;
screen[13] = B00011000;
screen[14] = B00011000;
screen[15] = B00011000;
screen[16] = B00000000;
screen[17] = B00000000;
screen[18] = B00000000;
screen[19] = B00000000;

screen[20] = B00000000;
screen[21] = B00000000;
screen[22] = B00000000;
screen[23] = B00000000;
screen[24] = B00011000;
screen[25] = B00011000;
screen[26] = B00011000;
screen[27] = B00011000;
screen[28] = B00011000;
screen[29] = B00011000;
screen[30] = B00011000;
screen[31] = B00011000;
screen[32] = B00000000;
screen[33] = B00000000;
screen[34] = B00000000;
screen[35] = B00000000;
screen[36] = B00000000;
screen[37] = B00000000;
screen[38] = B00000000;
screen[39] = B00000000;

  display();
  
  delay(random(200, 350));
  }  else {
     screen[0] = B00000000;
screen[1] = B00000000;
screen[2] = B00000000;
screen[3] = B00000000;
screen[4] = B00000000;
screen[5] = B00000000;
screen[6] = B00000000;
screen[7] = B00000000;
screen[8] = B00011000;
screen[9] = B00111100;
screen[10] = B01100110;
screen[11] = B01100110;
screen[12] = B01100110;
screen[13] = B01100110;
screen[14] = B00111100;
screen[15] = B00011000;
screen[16] = B00000000;
screen[17] = B00000000;
screen[18] = B00000000;
screen[19] = B00000000;

screen[20] = B00000000;
screen[21] = B00000000;
screen[22] = B00000000;
screen[23] = B00000000;
screen[24] = B00011000;
screen[25] = B00111100;
screen[26] = B01100110;
screen[27] = B01100110;
screen[28] = B01100110;
screen[29] = B01100110;
screen[30] = B00111100;
screen[31] = B00011000;
screen[32] = B00000000;
screen[33] = B00000000;
screen[34] = B00000000;
screen[35] = B00000000;
screen[36] = B00000000;
screen[37] = B00000000;
screen[38] = B00000000;
screen[39] = B00000000;

  }
}

Code Part 2

void effectHearts() {
  
screen[0] =  B00000000;
screen[1] =  B00000000;
screen[2] =  B00000000;
screen[3] =  B00000000;
screen[4] =  B00000000;
screen[5] =  B00000000;
screen[6] =  B00000000;
screen[7] =  B00000000;
screen[8] =  B00111000;
screen[9] =  B01111100;
screen[10] =  B01111110;
screen[11] =  B00111111;
screen[12] =  B01111110;
screen[13] =  B01111100;
screen[14] =  B00111000;
screen[15] =  B00000000;
screen[16] =  B00111000;
screen[17] =  B01111100;
screen[18] =  B01111110;
screen[19] =  B00111111;
screen[20] =  B01111110;
screen[21] =  B01111100;
screen[22] =  B00111000;
screen[23] =  B00000000;
screen[24] =  B00111000;
screen[25] =  B01111100;
screen[26] =  B01111110;
screen[27] =  B00111111;
screen[28] =  B01111110;
screen[29] =  B01111100;
screen[30] =  B00111000;
screen[31] =  B00000000;
screen[32] =  B00000000;
screen[33] =  B00000000;
screen[34] =  B00000000;
screen[35] =  B00000000;
screen[36] =  B00000000;
screen[37] =  B00000000;
screen[38] =  B00000000;
screen[39] =  B00000000;

for(int i = framePointer; i < 40; i++) {
  screen[i] = B00000000;
} 


if(framePointer > 40) {
for(int i = 0; i < (framePointer-40); i++) {
  screen[i] = B00000000;
} 
}

framePointer++;

if(framePointer > 80) {
  framePointer = 0;
}


}

void effectECG() {
  
screen[0] =  B00001100;
screen[1] =  B00011000;
screen[2] =  B00110000;
screen[3] =  B01100000;
screen[4] =  B00110000;
screen[5] =  B00011000;
screen[6] =  B00001100;
screen[7] =  B00000110;
screen[8] =  B00001100;
screen[9] =  B00011000;
screen[10] = B00110000;
screen[11] = B01100000;
screen[12] = B00110000;
screen[13] = B00011000;
screen[14] = B00001100;
screen[15] = B00000110;
screen[16] = B00001100;
screen[17] = B00011000;
screen[18] = B00110000;
screen[19] = B01100000;
screen[20] = B00110000;
screen[21] = B00011000;
screen[22] = B00001100;
screen[23] = B00000110;
screen[24] = B00001100;
screen[25] = B00011000;
screen[26] = B00110000;
screen[27] = B01100000;
screen[28] = B00110000;
screen[29] = B00011000;
screen[30] = B00001100;
screen[31] = B00000110;
screen[32] = B00001100;
screen[33] = B00011000;
screen[34] = B00110000;
screen[35] = B01100000;
screen[36] = B00110000;
screen[37] = B00011000;
screen[38] = B00001100;
screen[39] = B00000110;

for(int i = framePointer; i < 40; i++) {
  screen[i] = B00000000;
} 


if(framePointer > 40) {
for(int i = 0; i < (framePointer-40); i++) {
  screen[i] = B00000000;
} 
}

framePointer++;

if(framePointer > 80) {
  framePointer = 0;
}


}

void loadTextBuffers() {

// RAM
textBuffer[0][1] = B01111110;
textBuffer[0][2] = B01010000;
textBuffer[0][3] = B01011000;
textBuffer[0][4] = B01010100;
textBuffer[0][5] = B00100010;
textBuffer[0][6] = B00000000;
textBuffer[0][7] = B00000010;
textBuffer[0][8] = B00000000;
textBuffer[0][9] = B00011110;
textBuffer[0][10] = B00101000;
textBuffer[0][11] = B01001000;
textBuffer[0][12] = B00101000;
textBuffer[0][13] = B00011110;
textBuffer[0][14] = B00000000;
textBuffer[0][15] = B00000010;
textBuffer[0][16] = B00000000;
textBuffer[0][17] = B01111110;
textBuffer[0][18] = B00100000;
textBuffer[0][19] = B00010000;
textBuffer[0][20] = B00100000;
textBuffer[0][21] = B01111110;
textBuffer[0][22] = B00000000;
textBuffer[0][23] = B00000010;
textBuffer[0][24] = B00000000;






// Get Lucky
textBuffer[1][1] = B00111100;
textBuffer[1][2] = B01000010;
textBuffer[1][3] = B01000010;
textBuffer[1][4] = B01001010;
textBuffer[1][5] = B00001100;
textBuffer[1][6] = B00000000;
textBuffer[1][7] = B01111110;
textBuffer[1][8] = B01010010;
textBuffer[1][9] = B01010010;
textBuffer[1][10] = B01010010;
textBuffer[1][11] = B01000010;
textBuffer[1][12] = B00000000;
textBuffer[1][13] = B01000000;
textBuffer[1][14] = B01000000;
textBuffer[1][15] = B01111110;
textBuffer[1][16] = B01000000;
textBuffer[1][17] = B01000000;
textBuffer[1][18] = B00000000;
textBuffer[1][19] = B00000000;
textBuffer[1][20] = B00000000;
textBuffer[1][21] = B00000000;
textBuffer[1][22] = B00000000;
textBuffer[1][23] = B01111110;
textBuffer[1][24] = B00000010;
textBuffer[1][25] = B00000010;
textBuffer[1][26] = B00000010;
textBuffer[1][27] = B00000000;
textBuffer[1][28] = B01111100;
textBuffer[1][29] = B00000010;
textBuffer[1][30] = B00000010;
textBuffer[1][31] = B00000010;
textBuffer[1][32] = B01111100;
textBuffer[1][33] = B00000000;
textBuffer[1][34] = B00111100;
textBuffer[1][35] = B01000010;
textBuffer[1][36] = B01000010;
textBuffer[1][37] = B01000010;
textBuffer[1][38] = B00100100;
textBuffer[1][39] = B00000000;
textBuffer[1][40] = B01111110;
textBuffer[1][41] = B00011000;
textBuffer[1][42] = B00011000;
textBuffer[1][43] = B00100100;
textBuffer[1][44] = B01000010;
textBuffer[1][45] = B00000000;
textBuffer[1][46] = B01000000;
textBuffer[1][47] = B00100000;
textBuffer[1][48] = B00011110;
textBuffer[1][49] = B00100000;
textBuffer[1][50] = B01000000;
textBuffer[1][51] = B00000000;






// Daft Punk
textBuffer[2][0] = B01111110;
textBuffer[2][1] = B01000010;
textBuffer[2][2] = B01000010;
textBuffer[2][3] = B01000010;
textBuffer[2][4] = B00111100;
textBuffer[2][5] = B00000000;
textBuffer[2][6] = B00011110;
textBuffer[2][7] = B00101000;
textBuffer[2][8] = B01001000;
textBuffer[2][9] = B00101000;
textBuffer[2][10] = B00011110;
textBuffer[2][11] = B00000000;
textBuffer[2][12] = B01111110;
textBuffer[2][13] = B01010000;
textBuffer[2][14] = B01010000;
textBuffer[2][15] = B01010000;
textBuffer[2][16] = B01000000;
textBuffer[2][17] = B00000000;
textBuffer[2][18] = B01000000;
textBuffer[2][19] = B01000000;
textBuffer[2][20] = B01111110;
textBuffer[2][21] = B01000000;
textBuffer[2][22] = B01000000;
textBuffer[2][23] = B00000000;
textBuffer[2][24] = B00000000;
textBuffer[2][25] = B00000000;
textBuffer[2][26] = B00000000;
textBuffer[2][27] = B01111110;
textBuffer[2][28] = B01010000;
textBuffer[2][29] = B01010000;
textBuffer[2][30] = B01010000;
textBuffer[2][31] = B00100000;
textBuffer[2][32] = B00000000;
textBuffer[2][33] = B01111100;
textBuffer[2][34] = B00000010;
textBuffer[2][35] = B00000010;
textBuffer[2][36] = B00000010;
textBuffer[2][37] = B01111100;
textBuffer[2][38] = B00000000;
textBuffer[2][39] = B01111110;
textBuffer[2][40] = B00100000;
textBuffer[2][41] = B00010000;
textBuffer[2][42] = B00001000;
textBuffer[2][43] = B01111110;
textBuffer[2][44] = B00000000;
textBuffer[2][45] = B01111110;
textBuffer[2][46] = B00011000;
textBuffer[2][47] = B00011000;
textBuffer[2][48] = B00100100;
textBuffer[2][49] = B01000010;
textBuffer[2][50] = B00000000;



}

The problem is that I can not put into written more than a certain number of characters

You don't have a variable called written, so you can't put ANY characters into it.

You don't have a variable called written, so you can't put ANY characters into it.

Please can you tell me how and where I put this variable?
My programming knowledge is limited to the exchange of written and animations, the rest still is Arabic for me XD

If it's a variable that you are going to use all the time you should declare it as a "global variable" before any loop (so before setup() and before loop()). Like this you'll be able to use your variable written anywhere in your code.

Regarding the type of variable I didn't had the time to have a good look at your code but, you should choose a type that correspond to the type of data you want to "write". If it's a character, then declare a car, if it's a number a int... I guess you know a little bit of C, right ? If not, you should take a look to a tutorial first, to have that kind of basics =). Everything will be way easier if you know C.

If it's a variable that you are going to use all the time you should declare it as a "global variable" before any loop (so before setup() and before loop()). Like this you'll be able to use your variable written anywhere in your code.

Regarding the type of variable I didn't had the time to have a good look at your code but, you should choose a type that correspond to the type of data you want to "write". If it's a character, then declare a car, if it's a number a int... I guess you know a little bit of C, right ? If not, you should take a look to a tutorial first, to have that kind of basics =). Everything will be way easier if you know C.

I'm trying to learn C, I'm looking tutorial on youtube, I hope to do!
Thanks

You'll see, it's really easy once you get it =). And you don't need to know C as an expert but at least enough to write a program. Take care that Arduino uses C++ (but you should start with C).

Don't hesitate to come back here if you got questions =)

You'll see, it's really easy once you get it =). And you don't need to know C as an expert but at least enough to write a program. Take care that Arduino uses C++ (but you should start with C).

Don't hesitate to come back here if you got questions =)

Ok many thanks, I'll do it.