Interfacing 8x8 LED Dot Matrix with Arduino

In this simple project, we are going to learn how to Interface 8x8 LED Dot Matrix with Arduino.

Components and supplies

Jumper wires (generic)

LED Dot Matrix Display, Red

Apps and platforms

1//We always have to include the library 2#include "LedControl.h" 3 4/* 5 Now we need a LedControl to work with. 6 ***** These pin numbers will probably not work with your hardware ***** 7 pin 12 is connected to the DataIn 8 pin 11 is connected to LOAD(CS) 9 pin 10 is connected to the CLK 10 We have only a single MAX72XX. 11 */ 12LedControl lc=LedControl(12,10,11,1); 13 14/* image switching time */ 15unsigned long delaytime1=500; 16unsigned long delaytime2=50; 17void setup()  18 /* 19 The MAX72XX is in power-saving mode on startup, 20 we have to do a wakeup call 21 */ 22 lc.shutdown(0,false); 23 /* Set the brightness to a medium values */ 24 lc.setIntensity(0,8); 25 /* and clear the display */ 26 lc.clearDisplay(0); 27> 28 29/* 30 This method will display the characters for the 31 word "Arduino" one after the other on the matrix. 32 (you need at least 5x7 leds to see the whole chars) 33 */ 34void writeArduinoOnMatrix()  35 /* here is the data for the characters */ 36 byte a[5]=B01111110,B10001000,B10001000,B10001000,B01111110>; 37 byte r[5]=B00010000,B00100000,B00100000,B00010000,B00111110>; 38 byte d[5]=B11111110,B00010010,B00100010,B00100010,B00011100>; 39 byte u[5]=B00111110,B00000100,B00000010,B00000010,B00111100>; 40 byte i[5]=B00000000,B00000010,B10111110,B00100010,B00000000>; 41 byte n[5]=B00011110,B00100000,B00100000,B00010000,B00111110>; 42 byte o[5]=B00011100,B00100010,B00100010,B00100010,B00011100>; 43 44 /* now display them one by one with a small delay */ 45 lc.setRow(0,0,a[0]); 46 lc.setRow(0,1,a[1]); 47 lc.setRow(0,2,a[2]); 48 lc.setRow(0,3,a[3]); 49 lc.setRow(0,4,a[4]); 50 delay(delaytime1); 51 lc.setRow(0,0,r[0]); 52 lc.setRow(0,1,r[1]); 53 lc.setRow(0,2,r[2]); 54 lc.setRow(0,3,r[3]); 55 lc.setRow(0,4,r[4]); 56 delay(delaytime1); 57 lc.setRow(0,0,d[0]); 58 lc.setRow(0,1,d[1]); 59 lc.setRow(0,2,d[2]); 60 lc.setRow(0,3,d[3]); 61 lc.setRow(0,4,d[4]); 62 delay(delaytime1); 63 lc.setRow(0,0,u[0]); 64 lc.setRow(0,1,u[1]); 65 lc.setRow(0,2,u[2]); 66 lc.setRow(0,3,u[3]); 67 lc.setRow(0,4,u[4]); 68 delay(delaytime1); 69 lc.setRow(0,0,i[0]); 70 lc.setRow(0,1,i[1]); 71 lc.setRow(0,2,i[2]); 72 lc.setRow(0,3,i[3]); 73 lc.setRow(0,4,i[4]); 74 delay(delaytime1); 75 lc.setRow(0,0,n[0]); 76 lc.setRow(0,1,n[1]); 77 lc.setRow(0,2,n[2]); 78 lc.setRow(0,3,n[3]); 79 lc.setRow(0,4,n[4]); 80 delay(delaytime1); 81 lc.setRow(0,0,o[0]); 82 lc.setRow(0,1,o[1]); 83 lc.setRow(0,2,o[2]); 84 lc.setRow(0,3,o[3]); 85 lc.setRow(0,4,o[4]); 86 delay(delaytime1); 87 lc.setRow(0,0,0); 88 lc.setRow(0,1,0); 89 lc.setRow(0,2,0); 90 lc.setRow(0,3,0); 91 lc.setRow(0,4,0); 92 delay(delaytime1); 93> 94 95/* 96 This function lights up some Leds in a row. 97 The pattern will be repeated on every row. 98 The pattern will blink along with the row-number. 99 row number 4 (index==3) will blink 4 times etc. 100 */ 101void rows()  102 for(int row=0;row8;row++)  103 delay(delaytime2); 104 lc.setRow(0,row,B10100000); 105 delay(delaytime2); 106 lc.setRow(0,row,(byte)0); 107 for(int i=0;irow;i++)  108 delay(delaytime2); 109 lc.setRow(0,row,B10100000); 110 delay(delaytime2); 111 lc.setRow(0,row,(byte)0); 112 > 113 > 114> 115 116/* 117 This function lights up some Leds in a column. 118 The pattern will be repeated on every column. 119 The pattern will blink along with the column-number. 120 column number 4 (index==3) will blink 4 times etc. 121 */ 122void columns()  123 for(int col=0;col8;col++)  124 delay(delaytime2); 125 lc.setColumn(0,col,B10100000); 126 delay(delaytime2); 127 lc.setColumn(0,col,(byte)0); 128 for(int i=0;icol;i++)  129 delay(delaytime2); 130 lc.setColumn(0,col,B10100000); 131 delay(delaytime2); 132 lc.setColumn(0,col,(byte)0); 133 > 134 > 135> 136 137/* 138 This function will light up every Led on the matrix. 139 The led will blink along with the row-number. 140 row number 4 (index==3) will blink 4 times etc. 141 */ 142void single()  143 for(int row=0;row8;row++)  144 for(int col=0;col8;col++)  145 delay(delaytime2); 146 lc.setLed(0,row,col,true); 147 delay(delaytime2); 148 for(int i=0;icol;i++)  149 lc.setLed(0,row,col,false); 150 delay(delaytime2); 151 lc.setLed(0,row,col,true); 152 delay(delaytime2); 153 > 154 > 155 > 156> 157 158void loop()  159 writeArduinoOnMatrix(); 160 rows(); 161 columns(); 162 single(); 163> 164

Schematic for the project

Schematic for the project

Schematic for the project

Schematic for the project