Menu Close

Arduino – LED Matrix

This tutorial explains how to use LED Matrix with Arduino.

1. Introduction:

In this tutorial, we will interface LED matrix with Arduino. LED matrix contains 64 LED’s in 2-dimensional pattern array, used to represent characters, symbols and images.

1.1 Working:

LED matrix are available in various dimensions. In this module, each LED is arranged in row and column. An LED is connected between row and column. If row gets positive voltage then column gets negative voltage.

Each LED is addressed by its row and column number and every column and row started with number 0 i.e 00, 01, 02, 03, 04, 05, 06, 07. So to display any number, alphabet or symbol we need to glow LED’s accordingly using their respective address.

2. Hardware required

S.No.ItemQuantity
1.Arduino 1
2.Dot LED Matrix 1
3.Male to Female Jumper Wires 5

3. Circuit Diagram

Make the following connections with Arduino-

4. Library File

Following library will be required to run this sketch. Download the zip file extract the same and copy this to your Arduino library folder.

This library file should be placed at the install folder of Arduino. I have a 64 bit Win7 OS and my Arduino library folder address is located at

C:\Program Files (x86)\Arduino\libraries 

You may download library file from here.

5. Programming

5.1 Program to display Alphabets or Numbers on LED Matrix.

You may download this Arduino Sketch from here.

#include <LedControl.h>

int DIN = 12;
int CS =  11;
int CLK = 10;

byte R[8]=     {0x7e,0x7e,0x62,0x7e,0x7c,0x66,0x66,0x66};
byte O[8]=     {0x3c,0x7e,0x66,0x66,0x66,0x66,0x7e,0x3c};
byte B[8]=     {0x7c,0x66,0x66,0x7e,0x7e,0x66,0x7e,0x7c};
byte I[8]=     {0x7e,0x7e,0x18,0x18,0x18,0x18,0x7e,0x7e};
byte N[8]=     {0x66,0x76,0x76,0x7e,0x6e,0x6e,0x66,0x66};
byte D[8]=     {0x7c,0x7e,0x66,0x66,0x66,0x66,0x7e,0x7c};
byte dot[8]=   {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18};
byte A[8]=     {0x3c,0x7e,0x66,0x66,0x7e,0x66,0x66,0x66};


LedControl lc=LedControl(DIN,CLK,CS,0);

void setup(){
 lc.shutdown(0,false);       //The MAX72XX is in power-saving mode on startup
 lc.setIntensity(0,15);      // Set the brightness to maximum value
 lc.clearDisplay(0);         // and clear the display
}

void loop()
{ 
  printEdu();
  lc.clearDisplay(0);
  delay(1000);
}

void printEdu()
{
  printByte(R);
  delay(1000);
  printByte(O);
  delay(1000);
  printByte(B);
  delay(1000);
  printByte(O);
  delay(1000);
  printByte(dot);
  delay(1000);
  printByte(I);
  delay(1000);
  printByte(N);
  delay(1000);
  printByte(D);
  delay(1000);
  printByte(I);
  delay(1000);
  printByte(A);
  delay(1000);
}

void printByte(byte character [])
{
  int i = 0;
  for(i=0;i<8;i++)
  {
    lc.setRow(0,i,character[i]);
  }
}


5.2 Program for Animated Display of upward direction.

You may download the Arduino Sketch for Animated Upward Direction from here.

#include <LedControl.h>

int DIN = 12;
int CS =  11;
int CLK = 10;

const byte IMAGES[][8]= 
{
  {0x18,0x3c,0x7e,0xdb,0x99,0x18,0x18,0x18},
  {0x3c,0x5e,0xdb,0x99,0x18,0x18,0x18,0x00},
  {0x7e,0xdb,0x99,0x18,0x18,0x18,0x00,0x00},
  {0xdb,0x99,0x18,0x18,0x18,0x00,0x00,0x00},
  {0x99,0x18,0x18,0x18,0x00,0x00,0x00,0x00},
  {0x18,0x18,0x18,0x00,0x00,0x00,0x00,0x18},
  {0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x3c},
  {0x18,0x00,0x00,0x00,0x00,0x18,0x3c,0x7e},
  {0x00,0x00,0x00,0x00,0x18,0x3c,0x7e,0xdb},
  {0x00,0x00,0x00,0x18,0x3c,0x7e,0xdb,0x99},
  {0x00,0x00,0x18,0x3c,0x7e,0xdb,0x99,0x18},
  {0x00,0x18,0x3c,0x7e,0xdb,0x99,0x18,0x18},
  {0x18,0x3c,0x7e,0xdb,0x99,0x18,0x18,0x18}
};

const int IMAGES_LEN = sizeof(IMAGES)/8;
LedControl display=LedControl(DIN,CLK,CS);

void setup(){
 display.shutdown(0,false);       //The MAX72XX is in power-saving mode on startup
 display.setIntensity(0,15);      // Set the brightness to maximum value
 display.clearDisplay(0);         // and clear the display
}
int i=0;
void loop()
{ 
  displayImage(IMAGES[i]);
  if(++i>=IMAGES_LEN)
  {
    i=0;
  }
  delay(500);
}
void displayImage(const byte* image)
{
  for (int i=0; i<8;i++)
{
 

for (int j=0; j<8;j++)
{
 display.setLed(0,i,j, bitRead(image[i],7-j)); 
  }
}
}


5.3 Program for Animated display of downward direction.

You may download the Arduino Sketch for Animated Downward Direction from here.

#include <LedControl.h>

int DIN = 12;
int CS =  11;
int CLK = 10;

const byte IMAGES[][8]= 
{
  {0x18,0x18,0x18,0x99,0xdb,0x7e,0x3c,0x18},
  {0x00,0x18,0x18,0x18,0x99,0xdb,0x7e,0x3c},
  {0x00,0x00,0x18,0x18,0x18,0x99,0xdb,0x7e},
  {0x00,0x00,0x00,0x18,0x18,0x18,0x99,0xdb},
  {0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x99},
  {0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x18},
  {0x3c,0x18,0x00,0x00,0x00,0x00,0x18,0x18},
  {0x7e,0x3c,0x18,0x00,0x00,0x00,0x00,0x18},
  {0xdb,0x7e,0x3c,0x18,0x00,0x00,0x00,0x00},
  {0x99,0xdb,0x7e,0x3c,0x18,0x00,0x00,0x00},
  {0x18,0x99,0xdb,0x7e,0x3c,0x18,0x00,0x00},
  {0x18,0x18,0x99,0xdb,0x7e,0x3c,0x18,0x00},
  {0x18,0x18,0x18,0x99,0xdb,0x7e,0x3c,0x18}
};

const int IMAGES_LEN = sizeof(IMAGES)/8;
LedControl display=LedControl(DIN,CLK,CS);

void setup(){
 display.shutdown(0,false);       //The MAX72XX is in power-saving mode on startup
 display.setIntensity(0,15);      // Set the brightness to maximum value
 display.clearDisplay(0);         // and clear the display
}
int i=0;
void loop()
{ 
  displayImage(IMAGES[i]);
  if(++i>=IMAGES_LEN)
  {
    i=0;
  }
  delay(500);
}
void displayImage(const byte* image)
{
  for (int i=0; i<8;i++)
{
 

for (int j=0; j<8;j++)
{
 display.setLed(0,i,j, bitRead(image[i],7-j)); 
  }
}
}


You may download the PDF of hex codes from here.

6. Output

LED Matrix will display alphabet, number or any symbol according to the hex code you write in Arduino IDE. 

LED Matrix output displays animated upward direction. Direction Arrow will scrolling from down to up.

LED Matrix output displays animated downward direction. Direction Arrow will scrolling from up to down. 

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
https://roboindia.com

Leave a Reply