Introduction: Led Matrix Using Arduino (5 X 7)

About: An Electronics engineer and a hobbyist. I love to keep experimenting with microcontrollers.

Hello everyone, today we will make a led matrix. This matrix will consist of 5 rows and 7 columns. And hence can be controlled using an Arduino Uno. This will be a simple straight forward project will no complex shift registers for scanning purpose. And you can also increase the size of the matrix by using an arduino mega board. In the code I have included some emoticons which can simply be created by manipulating the bits. So read the entire instructable to make this project.

Step 1: Let's Get the Supplies First

I recommend buying the components from UTSource.net . They provide high quality components at affordable rate delivered right at your door step. They also provide multilayered PCB's at very affordable rates. PCB Services Do check them out !!!

1. Arduino Uno x 1

2. LED's x 35 (I chose red ones, you can get any color of your choice. Also grab a few extra so convenience)

3. Resistors 220 ohm x 7

4. Male to Male headers x 1

5. Vero Board x 1

6. Male to Female header wires

Additional supplies - Solder iron & solder wire

Step 2: Circuit Diagram and Connections

The circuit diagram for the matrix is given above.

Sorry for my poor soldering skills here.

Now the connections are simple to understand but a bit tricky to solder. So let's start.

First I will explain the connections.

Connect all the led's as shown in the diagram above. The anodes of all the led's in a row should be connected together. And the cathodes in all columns should also be connected together.

Now connect a 220 ohm resistor to each column to limit the excess flow of current.

The formula to calculate the resistor value is simply the ohm's law.

The output pin voltage of the Arduino is around 4.8 V. And the current rating of each led is 20 mA. So simply by dividing the voltage by the current we get the resistance value.

R = V / I = 4.8 / 20 mA = 240 (The closest one to this value I could find was 220 ohm)

Once all the led's and resistors are soldered on a vero board. Its time to solder some male headers in order to make connections to the Arduino.

Now do the connections to the Arduino Board using the male to female header wires.

Connect the column pins to digital pins 2, 3, 9, 10, 11, 12 &13 (from left side)

And connect the row pins to digital pins 8, 7, 6, 5 & 4 (from the left)

You can connect as per your wish just change it in the code too.

Step 3: Code

I used this code from Hstrumpfer. So a huge thanks to him. I also added a few emoticons like a smiling face, a heart and a bouncing ball. Though they do not look great on such a small matrix. But what can we expect.

You can give it a try.

Copy the code from below.

/*<br> Credits - 
 Original code was written by hstrumpfer on instructable and I modified it to make it 5*7 
 matrix. So a huge thanks to him. And hope you enjoy this project.  
*/
byte BALL1[] = {
B0110000,
B1001000,
B1001000,
B0110000,
B0000000};
byte BALL2[] = {
B0000000,
B0011000,
B0100100,
B0100100,
B0011000};
byte BALL3[] = {
B0000000,
B0001100,
B0010010,
B0010010,
B0001100};
byte BALL4[] = {
B0000000,
B0000110,
B0001001,
B0001001,
B0000110};
byte heart[] = {
B0110110,
B1001001,
B0100010,
B0010100,
B0001000};
byte heart1[] = {
B0110110,
B1011101,
B0101010,
B0010100,
B0001000};
byte heart2[] = {
B0110110,
B1111111,
B0111110,
B0011100,
B0001000};
byte A[] = {
B0010000,
B0101000,
B1111100,
B1000100,
B1000100};
byte B[] = {
B1111000,
B1000100,
B1111000,
B1000100,
B1111000};
byte C[] = {
B1111100,
B1000000,
B1000000,
B1000000,
B1111100};
byte D[] = {
B1111000,
B1000100,
B1000100,
B1000100,
B1111000};
byte E[] = {
B1111100,
B1000000,
B1111000,
B1000000,
B1111100};
byte F[] = {
B1111100,
B1000000,
B1110000,
B1000000,
B1000000};
byte G[] = {
B1111100,
B1000000,
B1001100,
B1000100,
B0111000};
byte H[] = {
B1000100,
B1000100,
B1111100,
B1000100,
B1000100};
byte I[] = {
B0111000,
B0010000,
B0010000,
B0010000,
B0111000};
byte J[] = {
B1111100,
B0000100,
B0000100,
B1000100,
B0111000};
byte K[] = {
B0100100,
B0101000,
B0110000,
B0101000,
B0100100};
byte L[] = {
B1000000,
B1000000,
B1000000,
B1000000,
B1111000};
byte M[] = {
B0101000,
B1010100,
B1010100,
B1000100,
B1000100};
byte N[] = {
B1000100,
B1100100,
B1010100,
B1001100,
B1000100};
byte O[] = {
B0111000,
B1000100,
B1000100,
B1000100,
B0111000};
byte P[] = {
B1111000,
B1000100,
B1111000,
B1000000,
B1000000};
byte Q[] = {
B0111000,
B1000100,
B1010100,
B0111000,
B0010000};
byte R[] = {
B1111000,
B1000100,
B1111000,
B1000100,
B1000100};
byte S[] = {
B0111100,
B1000000,
B0111000,
B0000100,
B1111000};
byte T[] = {
B1111100,
B0010000,
B0010000,
B0010000,
B0010000};
byte U[] = {
B1000100,
B1000100,
B1000100,
B1000100,
B0111000};
byte V[] = {
B1000100,
B1000100,
B1000100,
B0101000,
B0010000};
byte W[] = {
B1000100,
B1000100,
B1010100,
B1010100,
B0101000};
byte X[] = {
B1000100,
B0101000,
B0010000,
B0101000,
B1000100};
byte Y[] = {
B1000100,
B0101000,
B0010000,
B0010000,
B0010000};
byte Z[] = {
B1111100,
B0001000,
B0010000,
B0100000,
B1111100};
byte n1[] = {
B0010000,
B0110000,
B1010000,
B0010000,
B1111100};
byte n2[] = {
B0110000,
B1001000,
B0010000,
B0100000,
B1111100};
byte n3[] = {
B0111000,
B1000100,
B0011000,
B1000100,
B0111000};
byte n4[] = {
B0011000,
B0101000,
B1111100,
B0001000,
B0001000};
byte n5[] = {
B1111100,
B1000000,
B1111000,
B0000100,
B1111000};
byte n6[] = {
B0111000,
B1000000,
B1111000,
B1000100,
B0111000};
byte n7[] = {
B1111100,
B0001000,
B0010000,
B0100000,
B1000000};
byte n8[] = {
B0111000,
B1000100,
B0111000,
B1000100,
B0111000};
byte n9[] = {
B0011100,
B0100100,
B0011100,
B0000100,
B0000100};
byte n0[] = {
B0111000,
B1100100,
B1010100,
B1001100,
B0111000};
byte smily[] = {
B0110110,
B0110110,
B0000000,
B1000001,
B0111110};
const int columnPins[] = { 2,3,9,10,11,12,13};
const int rowPins[] = { 8,7,6,5,4};
int incomingByte;
void setup() {
for (int i = 0; i < 14; i++)
{
Serial.begin(9600);
pinMode(rowPins[i], OUTPUT); // make all the LED pins outputs
pinMode(columnPins[i], OUTPUT);
digitalWrite(columnPins[i], HIGH); // disconnect column pins from Ground
}
}
void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'A') {
      show(A, 400);
    }
        if (incomingByte == 'B') {
      show(B, 400);
    }
        if (incomingByte == 'C') {
      show(C, 400);
    }
        if (incomingByte == 'D') {
      show(D, 400);
    }
        if (incomingByte == 'E') {
      show(E, 400);
    }
        if (incomingByte == 'F') {
      show(F, 400);
    }
        if (incomingByte == 'G') {
      show(G, 400);
    }
        if (incomingByte == 'H') {
      show(H, 400);
    }
        if (incomingByte == 'I') {
      show(I, 400);
    }
        if (incomingByte == 'J') {
      show(J, 400);
    }
        if (incomingByte == 'K') {
      show(K, 400);
    }
        if (incomingByte == 'L') {
      show(L, 400);
    }
        if (incomingByte == 'M') {
      show(M, 400);
    }
        if (incomingByte == 'N') {
      show(N, 400);
    }
        if (incomingByte == 'O') {
      show(O, 400);
    }
        if (incomingByte == 'P') {
      show(P, 400);
    }
        if (incomingByte == 'Q') {
      show(Q, 400);
    }
        if (incomingByte == 'R') {
      show(R, 400);
    }
        if (incomingByte == 'S') {
      show(S, 400);
    }
        if (incomingByte == 'T') {
      show(T, 400);
    }
        if (incomingByte == 'U') {
      show(U, 400);
    }
        if (incomingByte == 'V') {
      show(V, 400);
    }
        if (incomingByte == 'W') {
      show(W, 400);
    }
        if (incomingByte == 'X') {
      show(X, 400);
    }
        if (incomingByte == 'Y') {
      show(Y, 400);
    }
        if (incomingByte == 'Z') {
      show(Z, 400);
    }
        if (incomingByte == '0') {
      show(n0, 400);
    }
        if (incomingByte == '1') {
      show(n1, 400);
    }
        if (incomingByte == '2') {
      show(n2, 400);
    }
        if (incomingByte == '3') {
      show(n3, 400);
    }
        if (incomingByte == '4') {
      show(n4, 400);
    }
        if (incomingByte == '5') {
      show(n5, 400);
    }
        if (incomingByte == '6') {
      show(n6, 400);
    }
        if (incomingByte == '7') {
      show(n7, 400);
    }
        if (incomingByte == '8') {
      show(n8, 400);
    }
        if (incomingByte == '9') {
      show(n9, 400);
    }
        if (incomingByte == ' ') {
     delay(400);
    }
            if (incomingByte == '?') {
              for(int x=0;x<6;x++)
      {
      show(smily, 400);
      }
    }
            if (incomingByte == '>') {
              for(int x=0;x<6;x++)
      {
      show(heart, 400);
      }
    }
    if (incomingByte == '<') {
      for(int x=0;x<6;x++)
      {
      show(heart, 200);show(heart1, 200);show(heart2, 200);show(heart1, 200);show(heart, 200);
      }
    }
    if (incomingByte == ']') {
      for(int x=0;x<3;x++)
      {
      show(BALL1, 200);show(BALL2, 200);show(BALL3, 200);show(BALL4, 200);
      }
      }
     }
}
// routine to show a frame of an image stored in the array pointed to by the image parameter.
// the frame is repeated for the given duration in milliseconds
void show( byte * image, unsigned long duration)
{
unsigned long start = millis(); // begin timing the animation
while (start + duration > millis()) // loop until the duration period has passed
{
for(int row = 0; row < 5; row++)
{
digitalWrite(rowPins[row], HIGH); // connect row to +5 volts
for(int column = 0; column < 7; column++)
{
boolean pixel = bitRead(image[row],column);
if(pixel == 1)
{
digitalWrite(columnPins[column], LOW); // connect column to Gnd
}
delayMicroseconds(400); // a small delay for each LED
digitalWrite(columnPins[column], HIGH); // disconnect column from Gnd
}
digitalWrite(rowPins[row], LOW); // disconnect LEDs
}
}
}

You can create a matrix with more number of rows and columns. Just add the pins in these two instructions -

const int columnPins[] = { 2,3,9,10,11,12,13};
const int rowPins[] = { 8,7,6,5,4};

Step 4: Final Project

I have attached a video of the working of this matrix. You can also check out the images above to get a basic idea how the matrix looks like. Hope you like this simple diy matrix project. If yes, then please share it with your friends. Also follow me here to see my upcoming projects. That's it for today guys. See you soon with another project.