Pages: [1]   Go Down
Author Topic: 16x16 LED Matrix  (Read 405 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I purchased (hasn't arrived) a 16 x 16 matrix from http://www.emartee.com/Modules/bbs/frame.php?frameon=yes&referer=http%3A//www.emartee.com/Modules/bbs/viewthread.php%3Ftid%3D711%26extra%3Dpage%253D1 and I want to have it display an array which will later be programmed, but right now is static. However, I am not sure if the following code will work. Can someone proof read it.

Thanks

Code:
    int myArray[16*16] = {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,
              1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0}; //16x16 array;
   
    int A_port = 4;
    int B_port = 5;
    int C_port = 6;
    int D_port = 7;
   
    int OOE=2;
    int RCK=10;
    int SCKPin=9; //SCK is already defined as 13.
    int SER=8;
    int VCC=11;
    int GND=3;

void setup() {
   pinMode(2,OUTPUT);
   pinMode(3,OUTPUT);
   pinMode(4,OUTPUT);
   pinMode(5,OUTPUT);
   pinMode(6,OUTPUT);
   pinMode(7,OUTPUT);
   pinMode(8,OUTPUT);
   pinMode(9,OUTPUT);
   pinMode(10,OUTPUT);
   pinMode(11,OUTPUT);
   
   Serial.begin(9600);
   digitalWrite(OOE,HIGH);
   digitalWrite(VCC,HIGH);
   digitalWrite(GND,LOW);
   digitalWrite(SCKPin,LOW);
}

void loop() {

   
       for(int disrow=0;disrow<16;disrow++)            //scanning the row
       {
         digitalWrite(OOE,HIGH);
         digitalWrite(RCK,LOW);
         //loadoneline();                              //load the data of a row
         //sendoneline();                              //send the data of a row
         //sendPin(disrow);
         
         //SelectRow
         lightArray(disrow);
               
         digitalWrite(OOE,LOW);                     // enable the row scanning
         digitalWrite(RCK,HIGH);                    //light a row
         delay(1);
       }
   
 
 
}

void lightArray(int row)
{
  //Light the row
 
  Serial.print("Row: ");
  Serial.print(row);
  Serial.print(" ");
 
  switch (row){
case 0:
digitalWrite(A_port , 0); digitalWrite(B_port , 0); digitalWrite(C_port,  0); digitalWrite(D_port , 0);
break;
case 1:
digitalWrite(A_port , 1); digitalWrite(B_port , 0); digitalWrite(C_port,  0); digitalWrite(D_port , 0);
break;
case 2:
digitalWrite(A_port , 0); digitalWrite(B_port , 1); digitalWrite(C_port,  0); digitalWrite(D_port , 0);
break;
case 3:
digitalWrite(A_port , 1); digitalWrite(B_port , 1); digitalWrite(C_port,  0); digitalWrite(D_port , 0);
break;
case 4:
digitalWrite(A_port , 0); digitalWrite(B_port , 0); digitalWrite(C_port,  1); digitalWrite(D_port , 0);
break;
case 5:
digitalWrite(A_port , 1); digitalWrite(B_port , 0); digitalWrite(C_port,  1); digitalWrite(D_port , 0);
break;
case 6:
digitalWrite(A_port , 0); digitalWrite(B_port , 1); digitalWrite(C_port,  1); digitalWrite(D_port , 0);
break;
case 7:
digitalWrite(A_port , 1); digitalWrite(B_port , 1); digitalWrite(C_port,  1); digitalWrite(D_port , 0);
break;
case 8:
digitalWrite(A_port , 0); digitalWrite(B_port , 0); digitalWrite(C_port,  0); digitalWrite(D_port , 1);
break;
case 9:
digitalWrite(A_port , 1); digitalWrite(B_port , 0); digitalWrite(C_port,  0); digitalWrite(D_port , 1);
break;
case 10:
digitalWrite(A_port , 0); digitalWrite(B_port , 1); digitalWrite(C_port,  0); digitalWrite(D_port , 1);
break;
case 11:
digitalWrite(A_port , 1); digitalWrite(B_port , 1); digitalWrite(C_port,  0); digitalWrite(D_port , 1);
break;
case 12:
digitalWrite(A_port , 0); digitalWrite(B_port , 0); digitalWrite(C_port,  1); digitalWrite(D_port , 1);
break;
case 13:
digitalWrite(A_port , 1); digitalWrite(B_port , 0); digitalWrite(C_port,  1); digitalWrite(D_port , 1);
break;
case 14:
digitalWrite(A_port , 0); digitalWrite(B_port , 1); digitalWrite(C_port,  1); digitalWrite(D_port , 1);
break;
case 15:
digitalWrite(A_port , 1); digitalWrite(B_port , 1); digitalWrite(C_port,  1); digitalWrite(D_port , 1);
break;
}
 
  //Light the columns
 
  for(int i = 0; i<numShifters;i++)
  {
  digitalWrite(RCLK_Pin,LOW);
  for (int n=0;n<8*numShifters;n++)
   {
      digitalWrite(SRCLK_Pin,LOW);
      if(myArray[row*n] == 1)
      {
        digitalWrite(SER_Pin,LOW);
        Serial.print("H ");
      }
      else
      {
        digitalWrite(SER,HIGH);
        Serial.print("L ");
      }
      //j=j>>1; //bitshift
      digitalWrite(SRCLK_Pin,HIGH);
                //delay(1);
   }
   digitalWrite(RCLK_Pin,HIGH);
  }
 
 Serial.println(); 
}

Logged

Pages: [1]   Go Up
Jump to: