animation problems with 24x6 matrix led [SOLVED]

Hi! I make this matrix led: http://www.instructables.com/id/Make-a-24X6-LED-matrix/?ALLSTEPS and it works fine but the include sketch only show a looping text.
I made my own code for make animations pattern to pattern but now i have a problem. When the number of patters is greater than 50 the matrix goes crazy. :S

what is the problem? this is the code (with only 30 patterns):

#define NUM_LETRAS 30  //define el numero de patrones

unsigned int letras[30][18] = {  //lo mismo, numero de patrones
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00010000,B00000000,B00000000,B00110000,B00000000,B00000000,B01100000,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00001100,B00000000,B00000000,B00011100,B00000000,B00000000,B00110000,B00000000,B00000000,B01100000,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000000,B00000000,B00110011,B00000000,B00000000,B01100001,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000000,B00000000,B00110011,B00000000,B00000000,B01100001,B10000000,B00000000,B11000000,B11000000,B00000000,B10000000,B01000000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000000,B00000000,B00110011,B00000000,B00000000,B01100001,B10010000,B00000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000100,B00000000,B00110011,B00001100,B00000000,B01100001,B10011000,B00000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B00000000,B00110011,B00001100,B00000000,B01100001,B10011000,B00000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000000,B00110011,B00001100,B11000000,B01100001,B10011000,B01000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000000,B00110011,B00001100,B11000000,B01100001,B10011000,B01000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000000,B00110011,B00001100,B11000000,B01100001,B10011000,B01100100,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B01100001,B10011000,B01100110,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B01100001,B10011000,B01100110,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B01100001,B10011000,B01100110,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B00100001,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00001110,B00000111,B10000001,B00000011,B00001100,B11000011,B00000001,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00000000,B00000011,B00000000,B00000010,B00000111,B10000001,B00000011,B00001100,B11000011,B00000001,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000111,B10000001,B00000000,B00001100,B11000011,B00000000,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000111,B10000001,B00000000,B00001100,B11000011,B00000000,B00011000,B01100110,B00000000,B00110000,B00111100,B00000000,B00100000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000111,B10000001,B00000000,B00001100,B11000011,B00000000,B00001000,B01100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000011,B10000001,B00000000,B00000000,B11000011,B00000000,B00000000,B01100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B10000001,B00000000,B00000000,B11000011,B00000000,B00000000,B01100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000,B00000011,B00000000,B00000000,B00100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000,B00000011,B00000000,B00000000,B00000110,B00000000,B00000000,B00001100,B00000000,B00000000,B00001000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000,B00000011,B00000000,B00000000,B00000010,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},

};
//byte n[3] = {B00000000,B00000000,B00000001};
int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int j = 6;
void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
}
void loop(){
// Select the first row
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
  for(int letra = 0 ; letra <= NUM_LETRAS ; letra++ )
  {
    for(int i=0;i<=5;i++)  // For each row
    {
      // Send 24 bits to the shift registers
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3+1]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3+2]);
      digitalWrite(latchPin, HIGH);
      digitalWrite(latchPin, LOW);
      delay(2); // Este delay define el tiempo en reproducir cada patron.  Increase delay to increase brightness.  Decrease to reduce flicker.
      // Clear the row so we can go on to the next row without smearing
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      digitalWrite(latchPin, HIGH);
      digitalWrite(latchPin, LOW);
      // On to the next row.
      digitalWrite(clock,HIGH);
      digitalWrite(clock,LOW);
    }
    digitalWrite(Reset,HIGH);
    digitalWrite(Reset,LOW);
    delay(10); //este delay define el tiempo en cambiar de un patron a otro
    if(letra == (NUM_LETRAS -1) ) {
      letra = -1;
    }
    
  }      
  
 }

With this code the matrix works fine, but if change and add more than 50 patterns crash :S
I try to change de "int letras" for long but doesn't work.

thanks!

pd: the matrix uses 3 shift registers and 1 decade counter.

It sounds as though you are running out of SRAM. Using unsigned char instead of unsigned int would help.

unsigned int letras[30][18] = {  //lo mismo, numero de patrones

30 * 18 * 2 = 1080 - that's quite a big chunk of your RAM, but not all of it. It should fit fine.

However ... why?
You're storing bytes in ints, so 50% is being wasted (make it byte, not int) and it's not an array you ever write to, so put it in PROGMEM and use pgm_read_byte() to get at the data.

Now, for animation - what I would suggest you DO use your RAM for is a framebuffer. Build up your animation frame in a 24x6-bit (3x6 byte) array and push the entire frame out to the display in one go. That way you can manipulate the image in nice interesting ways.

Even better would be to make the whole display updating timer based, so all you have to do is write to your framebuffer and it's instantly reflected in a change to the LEDs of the matrix.

majenko, any example?(using my code) i dont have idea to use the framebuffer:S and how i can change the int for byte in my code? actually (with 70 patterns) works fine but is hard to make the animations (i make a program in vb.net to help me)

thanks for reply :slight_smile:

You can switch to byte by changing the phrase "unsigned int" to "byte", since all the data in that array is 8-bit (i.e., byte) anyway.

And no, no "examples" using your code - that would entail me writing your program for you, and I'm not about to do that :stuck_out_tongue:

hehe, sorry my only intention is learn. And sorry for my english :slight_smile:

I change the int for byte but when add more than 100 patterns the problem continue. Any other idea?

And thanks again for your replys, really.

The fact that you have halved the memory use of each entry in the array, and you can now have twice as many entries in the array before you crash, points to memory exhaustion.

100*18 = 1800, which is pretty much all of your RAM.

You really NEED to move it to PROGMEM

hey again! I try to use the progmem but irs very difficult :S I think i was make something wrong.

this is my new code to declare de variable:

#define NUM_LETRAS 100  //define el numero de patrones
#include <avr/pgmspace.h>

byte letras[100][18] PROGMEM = {

With this code the matrix works with some issues. What is the problem? i thinks the problem comes from the read funcion but i not sure :S

Thanks again for your time :frowning:

It could be, who can say? Show us the latest version of your full code, including the bit you should have changed to get the data from the array using pgm_read_byte().

Thanks again majenko, my english its very bad i know. This is my actual code:

#define NUM_LETRAS 100  //define el numero de patrones
#include <avr/pgmspace.h>

byte letras[100][18] PROGMEM = {  //lo mismo, numero de patrones
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B01000000,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00010000,B00000000,B00000000,B00110000,B00000000,B00000000,B01100000,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00001100,B00000000,B00000000,B00011100,B00000000,B00000000,B00110000,B00000000,B00000000,B01100000,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000000,B00000000,B00110011,B00000000,B00000000,B01100001,B00000000,B00000000,B11000000,B00000000,B00000000,B10000000,B00000000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000000,B00000000,B00110011,B00000000,B00000000,B01100001,B10000000,B00000000,B11000000,B11000000,B00000000,B10000000,B01000000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000000,B00000000,B00110011,B00000000,B00000000,B01100001,B10010000,B00000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000000,B00000000,B00011110,B00000100,B00000000,B00110011,B00001100,B00000000,B01100001,B10011000,B00000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B00000000,B00110011,B00001100,B00000000,B01100001,B10011000,B00000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000000,B00110011,B00001100,B11000000,B01100001,B10011000,B01000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000000,B00110011,B00001100,B11000000,B01100001,B10011000,B01000000,B11000000,B11110000,B00000000,B10000000,B01100000,B00000000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000000,B00110011,B00001100,B11000000,B01100001,B10011000,B01100100,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B01100001,B10011000,B01100110,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B01100001,B10011000,B01100110,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B01100001,B10011000,B01100110,B11000000,B11110000,B00111100,B10000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00011110,B00000111,B10000001,B00110011,B00001100,B11000011,B00100001,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00001100,B00000011,B00000000,B00001110,B00000111,B10000001,B00000011,B00001100,B11000011,B00000001,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00000000,B00000011,B00000000,B00000010,B00000111,B10000001,B00000011,B00001100,B11000011,B00000001,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000111,B10000001,B00000000,B00001100,B11000011,B00000000,B10011000,B01100110,B00000000,B11110000,B00111100,B00000000,B01100000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000111,B10000001,B00000000,B00001100,B11000011,B00000000,B00011000,B01100110,B00000000,B00110000,B00111100,B00000000,B00100000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000111,B10000001,B00000000,B00001100,B11000011,B00000000,B00001000,B01100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000011,B00000000,B00000000,B00000011,B10000001,B00000000,B00000000,B11000011,B00000000,B00000000,B01100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B10000001,B00000000,B00000000,B11000011,B00000000,B00000000,B01100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000,B00000011,B00000000,B00000000,B00100110,B00000000,B00000000,B00111100,B00000000,B00000000,B00011000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000,B00000011,B00000000,B00000000,B00000110,B00000000,B00000000,B00001100,B00000000,B00000000,B00001000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000001,B00000000,B00000000,B00000011,B00000000,B00000000,B00000010,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},
{B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000},



};
//byte n[3] = {B00000000,B00000000,B00000001};
int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int j = 6;
void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
}
void loop(){
// Select the first row
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
  for(int letra = 0 ; letra <= NUM_LETRAS ; letra++ )
  {
    for(int i=0;i<=5;i++)  // For each row
    {
      // Send 24 bits to the shift registers
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3+1]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3+2]);
      digitalWrite(latchPin, HIGH);
      digitalWrite(latchPin, LOW);
      delay(2); // Este delay define el tiempo en reproducir cada patron.  Increase delay to increase brightness.  Decrease to reduce flicker.
      // Clear the row so we can go on to the next row without smearing
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      digitalWrite(latchPin, HIGH);
      digitalWrite(latchPin, LOW);
      // On to the next row.
      digitalWrite(clock,HIGH);
      digitalWrite(clock,LOW);
    }
    digitalWrite(Reset,HIGH);
    digitalWrite(Reset,LOW);
    delay(15); //este delay define el tiempo en cambiar de un patron a otro
    if(letra == (NUM_LETRAS -1) ) {
      letra = -1;
    }
    
  }      
  
 }

I delete some patterns for not exceed the length of the post.

      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3+1]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras[letra][i*3+2]);

Have you deliberately ignored my repeated mentions of pgm_read_byte() ?

Sorry majenko :blush: This is too difficult for me. Now i include de pgm_read_byte but doesn't work:

shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(letras[letra][i*3]));
      shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(letras[letra][i*3+1]));
      shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(letras[letra][i*3+2]));

Thank you again and my regards!

mntinside:
Sorry majenko :blush: This is too difficult for me. Now i include de pgm_read_byte but doesn't work:

shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(letras[letra][i*3]));

shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(letras[letra][i*3+1]));
      shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(letras[letra][i*3+2]));




Thank you again and my regards!

In what way is it not working?

The matrix works but makes strange things :S The leds works but not in the patterns sequence. :~

The code looks OK but it's hard to tell without spending weeks building the LED array for myself :wink:

One thing you could try is to add some delays - I notice in the example codes there is an 800µS delay in the latch toggling - you could try adding that, and similar for the clock and resets too:

      digitalWrite(latchPin, HIGH);
      delayMicroseconds(800); // Add this
      digitalWrite(latchPin, LOW);

The delay dont work. The problem is something about PROGMEM. If delete it, the matrix works fine. This is the code without PROGMEM, it shows a "M" in the middle of the matrix (static, without movement):

#include <avr/pgmspace.h>
#define NUM_LETRAS 10  //define el numero de patrones


byte letras[10][18] = {  //lo mismo, numero de patrones
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},
{00000000,B00100010,B00000000,B00000000,B00110110,B00000000,B00000000,B00101010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000,B00000000,B00100010,B00000000},

};
byte n[3] = {B00000000,B00000000,B00000001};
int latchPin = 10;
int clockPin = 13;
int dataPin = 11;
int clock = 9;
int Reset = 8;
int j = 6;
void setup(){
  Serial.begin(9600);
  pinMode(dataPin,OUTPUT);
  pinMode(clockPin,OUTPUT);
  pinMode(latchPin,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(Reset,OUTPUT);
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
}
void loop(){
// Select the first row
  digitalWrite(Reset,HIGH);
  digitalWrite(Reset,LOW);
  for(int letra = 0 ; letra <= NUM_LETRAS ; letra++ )
  {
    for(int i=0;i<=5;i++)  // For each row
    {
      // Send 24 bits to the shift registers
      shiftOut(dataPin, clockPin, MSBFIRST, letras [letra][i*3]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras [letra][i*3+1]);
      shiftOut(dataPin, clockPin, MSBFIRST, letras [letra][i*3+2]);
      digitalWrite(latchPin, HIGH);
      digitalWrite(latchPin, LOW);
      delay(2); // Este delay define el tiempo en reproducir cada patron.  Increase delay to increase brightness.  Decrease to reduce flicker.
      // Clear the row so we can go on to the next row without smearing
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      shiftOut(dataPin, clockPin, MSBFIRST, 0);
      digitalWrite(latchPin, HIGH);
      digitalWrite(latchPin, LOW);
      // On to the next row.
      digitalWrite(clock,HIGH);
      digitalWrite(clock,LOW);
    }
    digitalWrite(Reset,HIGH);
    digitalWrite(Reset,LOW);
    delay(15); //este delay define el tiempo en cambiar de un patron a otro
    if(letra == (NUM_LETRAS -1) ) {
      letra = -1;
    }
    
  }      
  
 }

If i add the progmem in the array and the delays, a lot of leds turn on and blink :S

It works!!!! I add the "&" before the letras like this:

      shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(&letras[letra][i*3]));
      shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(&letras[letra][i*3+1]));
      shiftOut(dataPin, clockPin, MSBFIRST, pgm_read_byte(&letras[letra][i*3+2]));

Thanks for your patience and for your help majenko! you are a genius :slight_smile: