K014 - LED Matrix Shield - How To Build & Sample Code


How to build

The LED matrix shield is supplied as a kit containing a PCB, 8 resistors, 4 sets of header pins, switch and 8x8 LED matrix.  Assembly is quite straightforward for anyone with moderate soldering experience.  If you are new to soldering, or need to brush up on your skills, there are lots of tutorial videos on YouTube and other websites.


Start with the 8 resistors.  The markings on the board show where they go.  They are all identical, and can be fitted either way around.  For neatness, though, we suggest mounting them all in the same direction.  Bend the legs at 90' before inserting them in to the board, and solder them in place one at a time.  Next mount the switch.  This will 'click' in to place on the PCB ready to be soldered.  The LED matrix must be orientated so that the writing on the edge is the same way around as the writing on the PCB.  Push it firmly through and solder in place.  All excess leads from resistors and matrix should be trimmed with a pair of side-cutters.  


To ensure the pins line up with your Arduino or Xino, insert the long ends in to the Arduino first and put the PCB on top before soldering the top of the board.


Aditional hardware may be wired up to digital pins 0 & 1 and anallog pins 0 & 1 via the solder pads next to the pins.  You could, if you wished, solder pins or sockets here to allow things to be added or removed as required.


LED matrix physical pinout


Sample code


The following code assumes two variable resistors have been wired to A0 and A1 as per this example;  http://arduino.cc/en/Tutorial/RowColumnScanning and allows you to move a single dot around the screen with the two pots;


  Row-Column Scanning an 8x8 LED matrix with X-Y input
 This example controls an 8x8 LED matrix using two analog inputs
 created 27 May 2009
 modified 30 Aug 2011
 by Tom Igoe
 This example works for the Lumex  LDM-24488NI Matrix. See 
 for the pin connections
 For other LED cathode column matrixes, you should only need to change 
 the pin numbers in the row[] and column[] arrays
 rows are the anodes
 cols are the cathodes
 Pin numbers:
 * Digital pins 2 through 13,
 * analog pins 2 through 5 used as digital 16 through 19
 * center pins are attached to analog pins 0 and 1, respectively
 * side pins attached to +5V and ground, respectively.
 This example code is in the public domain.
 see also http://www.tigoe.net/pcomp/code/category/arduinowiring/514 for more
// 2-dimensional array of row pin numbers:
const int row[8] = {
  2,7,19,5,13,18,12,16 };
// 2-dimensional array of column pin numbers:
const int col[8] = {
  6,11,10,3,17,4,8,9  };
// 2-dimensional array of pixels:
int pixels[8][8];           
// cursor position:
int x = 5;
int y = 5;
void setup() {
  // initialize the I/O pins as outputs:
  // iterate over the pins:
  for (int thisPin = 0; thisPin < 8; thisPin++) {
    // initialize the output pins:
    pinMode(col[thisPin], OUTPUT); 
    pinMode(row[thisPin], OUTPUT);  
    // take the col pins (i.e. the cathodes) high to ensure that
    // the LEDS are off: 
    digitalWrite(col[thisPin], HIGH);    
  // initialize the pixel matrix:
  for (int x = 0; x < 8; x++) {
    for (int y = 0; y < 8; y++) {
      pixels[x][y] = HIGH;
void loop() {
  // read input:
  // draw the screen:
void readSensors() {
  // turn off the last position:
  pixels[x][y] = HIGH;
  // read the sensors for X and Y values:
  x = 7 - map(analogRead(A0), 0, 1023, 0, 7);
  y = map(analogRead(A1), 0, 1023, 0, 7);
  // set the new pixel position low so that the LED will turn on
  // in the next screen refresh:
  pixels[x][y] = LOW;
void refreshScreen() {
  // iterate over the rows (anodes):
  for (int thisRow = 0; thisRow < 8; thisRow++) {
    // take the row pin (anode) high:
    digitalWrite(row[thisRow], HIGH);
    // iterate over the cols (cathodes):
    for (int thisCol = 0; thisCol < 8; thisCol++) {
      // get the state of the current pixel;
      int thisPixel = pixels[thisRow][thisCol];
      // when the row is HIGH and the col is LOW,
      // the LED where they meet turns on:
      digitalWrite(col[thisCol], thisPixel);
      // turn the pixel off:
      if (thisPixel == LOW) {
        digitalWrite(col[thisCol], HIGH);
    // take the row pin low to turn off the whole row:
    digitalWrite(row[thisRow], LOW);