Previously we shared many guides with TM1637 7 segment LED display. TM1637 was shown as it is mainly software based control, least knowledge on electronics needed. We actually discussed about MAX7219 in various articles like on increasing the number of pins of Arduino, This guide is on Arduino 8×8 LED Dot Matrix Display with MAX7219 code for testing for the beginners with one 8×8 LED Dot Matrix Board to get started. We made it obvious on LED bar display article that each LED on these boards is nothing but just another LED. In case of 8×8 LED Dot Matrix Display, these LED has common cathode. The same common cathode is used for single 7 segment LED display module. In a single 7 segment LED display, there is 8 and a dot. As we said before, one of the thing MAX7219 IC does is multiplexing – we can buy a separate MAX7219 IC and control LED, 7 segment LED etc. China 8×8 LED Dot Matrix Displays cost less than one MAX7219 IC! So, instead of buying a single MAX7219 IC plus 8×8 LED Dot Matrix, it is practical to buy them as module. Peoples usually add multiple 8×8 LED Dot Matrix Displays in real life to display text, graphics as sign board on public place. If we know to run 8×8 LED Dot Matrix Display with MAX7219, we can create Christmas of Diwali light with plain LED and MAX7219 IC – easy China like thought! So much written here for that reason :
1 | https://playground.arduino.cc/Main/MAX72XXHardware |
Arduino 8×8 LED Dot Matrix Display With MAX7219
These modules have 5 pins. For our and most guides, libraries the connection will be :
VCC connects to 5v of Arduino (always, constant)
GND connects to GND of Arduino (always, constant)
DIN connects to pin 12 of Arduino (variable)
CLK connects to pin 11 of Arduino (variable)
CS connects to pin 10 of Arduino (variable)
---
Please note that : the pins on the modules are serially VCC, GND, DIN, CS, CLK but usually libraries, and guides do not maintain the order of serial with respect to pin number. It is normal to connect in wrong pin and cry. For some reason, pin 12, 11, 10 works great for most of these displays.
Install these libraries :
1 2 | https://github.com/wayoda/LedControl https://github.com/AbhishekGhosh/Arduino_LED_matrix_sketch |
This is example code for 0 to 9 count display :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include "LedControlMS.h" /* Configuring the LEDMatrix: VCC connects to 5v of Arduino GND connects to GND of Arduino DIN connects to pin 12 of Arduino CLK connects to pin 11 of Arduino CS connects to pin 10 of Arduino There is only one MAX7219 display module. */ #define NBR_MTX 2 LedControl lc=LedControl(12,11,10, NBR_MTX); String sentence= "1234567890 "; int letterCounter=0; /* wait time between updates of the display */ unsigned long delaytime=300; void setup() { // initalizes and sets up the initial values. Declaring function setup. /* The display module is in power-saving mode on startup. Do a wakeup call */ Serial.begin(9600); // setting data rate as 9600 bits per second for serial data communication to computer Serial.println("Setup"); //prints data to serial port as human-readable text letterCounter=0; for (int i=0; i< NBR_MTX; i++){ lc.shutdown(i,false); //keep the screen on lc.setIntensity(i,8); // set brightness to medium values lc.clearDisplay(i); //clear the display after each letter } } void loop() { //declaring function loop char ch= sentence[letterCounter]; //define character ch letterCounter++; if (letterCounter>14) letterCounter=0; //sets up loop lc.displayChar(0, lc.getCharArrayPosition(ch)); //display each character on the screen delay(1000); lc.clearAll(); delay(2); } |
Here is video :
This code is good for making Christmas light, Diwali light made with up to 64 LEDs and MAX7219 IC :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include "LedControl.h" LedControl lc=LedControl(12,11,10,1); /* Set the time */ unsigned long delaytime=20; void setup() { lc.shutdown(0,false); /* Set the brightness */ lc.setIntensity(0,2); lc.clearDisplay(0); } void writeArduinoOnMatrix() { } void single() { for(int row=0;row<8;row++) { for(int col=0;col<8;col++) { delay(delaytime); lc.setLed(0,row,col,true); delay(delaytime); for(int i=0;i<col;i++) { lc.setLed(0,row,col,false); delay(delaytime); lc.setLed(0,row,col,true); delay(delaytime); } } } } void loop() { writeArduinoOnMatrix(); single(); lc.clearDisplay(0); } |
This code will animate :-| and :-( :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #include "LedControl.h" #include "binary.h" /* DIN connects to pin 12 CLK connects to pin 11 CS connects to pin 10 */ LedControl lc=LedControl(12,11,10,1); // delay time between faces unsigned long delaytime=1000; // happy face byte hf[8]= {B00111100,B01000010,B10100101,B10000001,B10100101,B10011001,B01000010,B00111100}; // neutral face byte nf[8]={B00111100, B01000010,B10100101,B10000001,B10111101,B10000001,B01000010,B00111100}; // sad face byte sf[8]= {B00111100,B01000010,B10100101,B10000001,B10011001,B10100101,B01000010,B00111100}; void setup() { lc.shutdown(0,false); // Set brightness to a medium value lc.setIntensity(0,8); // Clear the display lc.clearDisplay(0); } void drawFaces(){ // Display sad face lc.setRow(0,0,sf[0]); lc.setRow(0,1,sf[1]); lc.setRow(0,2,sf[2]); lc.setRow(0,3,sf[3]); lc.setRow(0,4,sf[4]); lc.setRow(0,5,sf[5]); lc.setRow(0,6,sf[6]); lc.setRow(0,7,sf[7]); delay(delaytime); // Display neutral face lc.setRow(0,0,nf[0]); lc.setRow(0,1,nf[1]); lc.setRow(0,2,nf[2]); lc.setRow(0,3,nf[3]); lc.setRow(0,4,nf[4]); lc.setRow(0,5,nf[5]); lc.setRow(0,6,nf[6]); lc.setRow(0,7,nf[7]); delay(delaytime); // Display happy face lc.setRow(0,0,hf[0]); lc.setRow(0,1,hf[1]); lc.setRow(0,2,hf[2]); lc.setRow(0,3,hf[3]); lc.setRow(0,4,hf[4]); lc.setRow(0,5,hf[5]); lc.setRow(0,6,hf[6]); lc.setRow(0,7,hf[7]); delay(delaytime); } void loop(){ drawFaces(); } |