How to use LED matrix using arduino


Materials:-

Diagram:-

Connections:-
  • LED matrix Vcc = Arduino 5V
  • LED matrix GND = Arduino GND
  • LED matrix DIN = Arduino Digital pin 12
  • LED matrix CS = Arduino Digital pin 11
  • LED matrix CLK = Arduino Digital pin 10
Downloads:-

Code :-

include <LedControl.h>


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

byte m[8]=     {0x00,0xE7,0xF7,0xFF,0xDB,0xDB,0xC3,0xC3};//you can change this
byte r[8]=     {0x00,0x3C,0x24,0x24,0x3C,0x38,0x24,0x24};
byte dot[8]=   {0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18};
byte a[8]=     {0x00,0x3C,0x7E,0x66,0x7E,0x66,0x66,0x66};
byte d[8]=     {0x78,0x7C,0x66,0x66,0x66,0x66,0x7C,0x78};
byte u[8]=     {0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x7E};
byte i[8]=     {0x00,0x18,0x18,0x00,0x18,0x18,0x18,0x18};
byte n[8]=     {0x00,0x66,0x76,0x7E,0x7E,0x6E,0x66,0x00};
byte o[8]=     {0x7E,0x7E,0x66,0x66,0x66,0x66,0x7E,0x7E};

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

void setup(){
 lc.shutdown(0,false);       
 lc.setIntensity(0,15);      // Set the brightness to maximum value
 lc.clearDisplay(0);         //  clear the display
}

void loop(){ 

    byte smile[8]=   {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};
    byte neutral[8]= {0x3C,0x42,0xA5,0x81,0xBD,0x81,0x42,0x3C};
    byte frown[8]=   {0x3C,0x42,0xA5,0x81,0x99,0xA5,0x42,0x3C};
    
    printByte(smile);
     
    delay(1000);

    printByte(neutral);
    
    delay(1000);

    printByte(frown);    

    delay(1000);
   
    printmrarduino();
   
    lc.clearDisplay(0);
    
    delay(1000);
}

void printmrarduino()
{
  printByte(m);
  delay(1000);
  printByte(r);
  delay(1000);
  printByte(dot);
  delay(1000);
  printByte(a);
  delay(1000);
  printByte(r);
  delay(1000);
  printByte(d);
  delay(1000);
  printByte(u);
  delay(1000);
  printByte(i);
  delay(1000);
  printByte(n);
  delay(1000);
  printByte(o);
  delay(1000);
}

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

}