Arduino – 8×8 LED Matrix

How to get an 8x8 LED Matrix working with an Arduino the simple way.

I bought myself an Arudiuo, it cost about $30 and basically lets me prototype electronics. It gives me a whole heap of input and outputs that I can use to input stuff into the computer, output stuff from the computer or just have it running by itself.

The first project I built was just some LED’s and flashing them, this second project is an 8×8 LED Matrix that I bought online off ebay. It cost me $16AUD with free postage for 10 of them.

Here is a video of it in action: http://www.youtube.com/watch?v=dYZcLuxIiZ8

There was little documentation on the thing, so I had to work it all out myself.

Here’s the model number and specs of it:
8×8 BiColour LED Matrix (Red/Green)
Product Number: LE-MM103
Markings: GYXM-1388ASRG2 EI4 943 4

Here’s a diagram I made that shows the pins.
Connected to my Arduino, I had them connected to inputs:
Rows (1-8):  10, 12, 15, 17, 2, 4, 6, 8
Columns (1-8): 11, 14, 16, 18, 3,  5,  7, 9

Note that outputs 14 and above are actually the Analogue outputs, where 14 = 0, 15 = 1 etc.

To display the images on the 8×8 Matrix, my code does the following:
Turns on a Column, then turns on the lights on that column. Then turns the column off and moves onto the next column.

It does this about 60 times a second, fast enough that you don’t even notice it.

Below is my code, note that I used the code from the Arduino Tutorials to work out how to get everything working.


/*
8x8 LED Matrix display code.
Built to work with the LE-MM103 8x8 BiColour LED Matrix (one colour only)
Markings on the Unit are:  GYXM-1388ASRG2 EI4 943 4

Created 23 Dec 2009
by Dustin Kerr

http://www.arduino.cc/en/Tutorial/RowColumnScanning

see also http://www.tigoe.net/pcomp/code/category/arduinowiring/514 for more
*/

// 2-dimensional array of row pin numbers:
const int rownum[8] = {
10,12,15,17,2,4,6,8 };
// 2-dimensional array of column pin numbers:
const int colnum[8] = {
11,14,16,18,3,5,7,9  };

float timeCount = 0;

int h[8][8] = {
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,1,1,1,1,0},
{0,0,1,1,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0}};

int e[8][8] = {
{0,0,1,1,1,1,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,1,1,1,0},
{0,0,0,0,1,1,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,1,1,1,1,1,0}};

int l[8][8] = {
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,1,0},
{0,0,1,1,1,1,1,0}};

int o[8][8] = {
{0,0,0,1,1,1,0,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,0,1,1,1,0,0}};

int smile[8][8] = {
{0,0,0,0,0,0,0,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,1,1,0},
{0,0,0,0,0,0,0,0},
{0,1,0,0,0,0,1,0},
{0,0,1,0,0,1,0,0},
{0,0,0,1,1,0,0,0}};

int blank[8][8] = {
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}};

void setup() {
Serial.begin(9600);
// initialize the I/O pins as outputs:

// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(colnum[thisPin], OUTPUT);
pinMode(rownum[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(colnum[thisPin], LOW);
digitalWrite(rownum[thisPin], HIGH);
}

}

void loop() {
// This could be rewritten to not use a delay, which would make it appear brighter
delay(5);
timeCount += 1;
if(timeCount < 200) {
drawScreen(h);
} else if (timeCount < 230) {
// do nothing
} else if (timeCount < 400) {
drawScreen(e);
} else if (timeCount < 430) {
// nothing
} else if (timeCount < 600) {
drawScreen(l);
} else if (timeCount < 630) {
// nothing
} else if (timeCount < 800) {
drawScreen(l);
} else if (timeCount < 830) {
// nothing
} else if (timeCount < 1000) {
drawScreen(o);
} else if (timeCount < 1030) {
// nothing
} else if (timeCount < 1200) {
drawScreen(smile);
} else if (timeCount < 1230) {
// nothing
} else {
// back to the start
timeCount = 0;
}
}

int row(int i) {
if(i == 1) {
return 10;
} else if (i == 2) {
return 12;
} else if (i == 3) {
return 15;
} else if (i == 4) {
return 17;
} else if (i == 5) {
return 2;
} else if (i == 6) {
return 4;
} else if (i == 7) {
return 6;
} else if (i == 8) {
return 8;
}
}

int col(int i) {
if(i == 1) {
return 11;
} else if (i == 2) {
return 14;
} else if (i == 3) {
return 16;
} else if (i == 4) {
return 18;
} else if (i == 5) {
return 3;
} else if (i == 6) {
return 5;
} else if (i == 7) {
return 7;
} else if (i == 8) {
return 9;
}
}

void drawScreen(int character[8][8]) {
for(int j = 0; j < 8; j++) {
// Turn the row on
int rowNumber = j + 1;
digitalWrite(row(rowNumber), LOW);
for (int k = 0; k < 8; k++) {
// draw some letter bits
int columnNumber = k + 1;
if(character[j][k] == 1) {
digitalWrite(col(columnNumber), HIGH);
}

digitalWrite(col(columnNumber), LOW);
}
digitalWrite(row(rowNumber), HIGH);
}
}

And of course, indenting and all that is broken by WordPress 😛

If you found this useful, please leave a comment =]

Ducky

4 comments

Fabian Becerra

Thanks a ton for creating and sharing this documentation. I bought the same LED matrix on e-bay but could not find any info on it. This will definitely be a huge time saver.

No worries, that’s why I posted it 😛