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.