My counter stop working when i call a function

file:///Users/jorgequintero/Desktop/Captura%20de%20pantalla%202016-01-10%20a%20las%202.04.48%20p.m..png

file:///Users/jorgequintero/Desktop/Captura%20de%20pantalla%202016-01-10%20a%20las%202.05.05%20p.m..png

Hello everyone, I have been trying to get a counter and I have got this, the problem appears when I call a function, it stop working, I have tried many ways to get the counter working but it just dont :s

First picture is my counter working, on the second one it's when I have called my function (named pelotas)

This is my code, kind of long(?) :s

int col[]={2,9};
     int col2[]={3,4,5,6,7,8};
     int fila[]={10,11,12,13,14,15,16,17};
     int s=0;
     
     
void setup()                           // Prog_37_1
   {   
   
        for (int i=0;i<=1;i++)
        {
   pinMode(col[i],OUTPUT);  
   digitalWrite(col[i],HIGH);
        }

    for (int i=0;i<=5;i++)
        {
   pinMode(col2[i],OUTPUT);  
   digitalWrite(col2[i],HIGH);
        }


    for(int t=0;t<=7;t++)
        {
   pinMode(fila[t],OUTPUT);
   digitalWrite(fila[t],LOW);
         }
        
        pinMode(19,INPUT);
         pinMode(18,INPUT);
        Serial.begin(9600);
   }
   
   
   
   void loop ()
   {
   plataformas();
   s=s+1;
   Serial.println(s);
   pelota(s);                  ->>>>>>>> Here is when I get the trouble :c
     
   } 
  
 
   
void plataformas()

{
  
   
   
   int matriz[2][8];  //Creamos la matriz para las dos plataformas
   
   
     for (int t=0;t<8;t++)
   {
     matriz[0][t]=0; //Siempre hay que llenarlas con 0, eso significara que ese punto esta apagado
     matriz[1][t]=0; //Llenando con 0
    }
    
 

    int  l= (analogRead(19))/147;  //Tomamos la medida del potenciometro, esto nos indicara donde se desea poner la plataforma
    int  y= (analogRead(18))/147;  //Tomamos la medida del potenciometro, esto nos indicara donde se desea poner la plataforma
    
     matriz[0][y]=1;     //Asignamos 1 a estos puntos, 1 significara prendido
     matriz[0][y+1]=1;   //Asignamos 1 a estos puntos, 1 significara prendido
     matriz[1][l]=1;     //Asignamos 1 a estos puntos, 1 significara prendido
     matriz[1][l+1]=1;   //Asignamos 1 a estos puntos, 1 significara prendido

     
  
 for (int x=0;x<2;x++)   //Debido a que no se pueden prender de la forma en que se quieren los leds, lo que se hace es prenderlos y apagarlos de a uno por uno, tan rapido, que parece que todos estuvieran prendidos al tiempo
 {
   for (int y=0;y<8;y++)
   {
   
    if(matriz[x][y]==1)  //Se recorre la matriz en busca de 1, es decir leds prendidos
    {         
    digitalWrite(col[x],LOW);   //Se prende el catodo
    digitalWrite(fila[y],HIGH); //Se prende el anodo
    delay(1);
    digitalWrite(col[x],HIGH);   //Se apaga el catodo
    digitalWrite(fila[y],LOW);   //Se apaga el anodo
   }    
   }
 }
 }
 

void pelota (int a)
{
  
   int matriz1[5][8];
     for (int m=0;m<6;m++)
   {
        for (int b=0;b<8;b++)
       {
       matriz1[m][b]=0; //Llenando con 0
       matriz1[m][b]=0; //Llenando con 0
   
       }
   }     
  
  matriz1[a][3]=1;
  
  for (int x=0;x<6;x++)   //Debido a que no se pueden prender de la forma en que se quieren los leds, lo que se hace es prenderlos y apagarlos de a uno por uno, tan rapido, que parece que todos estuvieran prendidos al tiempo
 {
   for (int y=0;y<8;y++)
   {
   
    if(matriz1[x][y]==1)  //Se recorre la matriz en busca de 1, es decir leds prendidos
    {         
    digitalWrite(col2[x],LOW);   //Se prende el catodo
    digitalWrite(fila[y],HIGH); //Se prende el anodo
    delay(1);
    digitalWrite(col2[x],HIGH);   //Se apaga el catodo
    digitalWrite(fila[y],LOW);   //Se apaga el anodo
   }    
   }
   
   
   
 }
}

Here you write outside your array. The array is 5x8, but you try to fill 6x8 entries.

void pelota (int a)
{
 int matriz1[5][8];
 for (int m=0;m<6;m++)
 {
   for (int b=0;b<8;b++)
   {
     matriz1[m][b]=0; //Llenando con 0
     matriz1[m][b]=0; //Llenando con 0

Here you will write outside your array as soon as your counter is greater than 4, which is pretty quickly.

	matriz1[a][3]=1;

This may cause you to overwrite the memory address where s is stored, among other things.

:ooo

Thanks bro, I havent think about it, yeah, the problem is with the matriz's size, the counter make pretty big and matriz does not have that size