Wednesday, July 23, 2014

Programmable LED MATRIX [ARDUINO]


This led matrix can be programmed using arduino, various patterns can be made using functions and by specifying the LED's on the array.

components-

transistors- BC547
Resistances- 470 ohm and 1K ohm
Arduino Uno
hookup wires
breadboard

Circuit Schematic-



Sketch-

int x [4] = {13,12,11,4}; //Pins of x axis in numerical order
int y [4] = {10,7,8,2}; //Pins of y axis in numerical order
void setup ()
{
 for (int a=0; a<4; a++) { //Output pins
 pinMode(x[a], OUTPUT);
 }
  for (int b=0; b<4; b++) { //Output pins
 pinMode(y[b], OUTPUT);
 }
}
void flash (int x1,int y1) { //Function to flash leds
  x1-=1; //-1 because arrays starts with 0 so the 4 is 3 and 3 is 2...
  y1-=1;
  for (int c=0; c<4;c++) {
if(c!=x_){ //This will turn off every single x led except the led you wanna flash
  digitalWrite(x[c], LOW);
}
  }
  for (int d=0; d<4;d++) {
if(d!=y_){ //This will turn off every single y led except the led you wanna flash
digitalWrite(y[d], LOW);
}
  }
  digitalWrite(x[(x1)],HIGH); 
  delay(80);
  //Flashes the x led you want to
  digitalWrite(y[(y1)],HIGH);
  delay(80);
}

void loop () {

flash(1,1);
flash(1,2);
flash(1,3);
flash(1,4);
flash(2,1);
flash(2,2);
flash(2,3);
flash(2,4);
flash(3,1);
flash(3,2);
flash(3,3);
flash(3,4);
flash(4,1);
flash(4,2);
flash(4,3);
flash(4,4);

flash(1,1);
flash(2,1);
flash(3,1);
flash(4,1);
flash(1,2);
flash(2,2);
flash(3,2);
flash(4,2);
flash(1,3);
flash(2,3);
flash(3,3);
flash(4,3);
flash(1,4);
flash(2,4);
flash(3,4);
flash(4,4);


}

Programmable LED MATRIX [ARDUINO] video DEMO
























No comments:

Post a Comment