Components and supplies
LED Dot Matrix Display, Red
Male/Female Jumper Wires
Arduino Mega 2560
Apps and platforms
Arduino IDE
Project description
Code
Code
c_cpp
Copy/paste code
1//www.elegoo.com 2//2016.12.9 3 4//We always have to include the library 5#include "LedControl.h" 6 7/* 8 Now we need a LedControl to work with. 9 ***** These pin numbers will probably not work with your hardware ***** 10 pin 12 is connected to the DataIn 11 pin 11 is connected to LOAD(CS) 12 pin 10 is connected to the CLK 13 We have only a single MAX72XX. 14 */ 15LedControl lc=LedControl(12,10,11,1); 16 17/* we always wait a bit between updates of the display */ 18unsigned long delaytime1=500; 19unsigned long delaytime2=50; 20void setup() { 21 /* 22 The MAX72XX is in power-saving mode on startup, 23 we have to do a wakeup call 24 */ 25 lc.shutdown(0,false); 26 /* Set the brightness to a medium values */ 27 lc.setIntensity(0,8); 28 /* and clear the display */ 29 lc.clearDisplay(0); 30} 31 32/* 33 This method will display the characters for the 34 word "Arduino" one after the other on the matrix. 35 (you need at least 5x7 leds to see the whole chars) 36 */ 37void writeArduinoOnMatrix() { 38 /* here is the data for the characters */ 39 byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110}; 40 byte r[5]={B00010000,B00100000,B00100000,B00010000,B00111110}; 41 byte d[5]={B11111110,B00010010,B00100010,B00100010,B00011100}; 42 byte u[5]={B00111110,B00000100,B00000010,B00000010,B00111100}; 43 byte i[5]={B00000000,B00000010,B10111110,B00100010,B00000000}; 44 byte n[5]={B00011110,B00100000,B00100000,B00010000,B00111110}; 45 byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100}; 46 47 /* now display them one by one with a small delay */ 48 lc.setRow(0,0,a[0]); 49 lc.setRow(0,1,a[1]); 50 lc.setRow(0,2,a[2]); 51 lc.setRow(0,3,a[3]); 52 lc.setRow(0,4,a[4]); 53 delay(delaytime1); 54 lc.setRow(0,0,r[0]); 55 lc.setRow(0,1,r[1]); 56 lc.setRow(0,2,r[2]); 57 lc.setRow(0,3,r[3]); 58 lc.setRow(0,4,r[4]); 59 delay(delaytime1); 60 lc.setRow(0,0,d[0]); 61 lc.setRow(0,1,d[1]); 62 lc.setRow(0,2,d[2]); 63 lc.setRow(0,3,d[3]); 64 lc.setRow(0,4,d[4]); 65 delay(delaytime1); 66 lc.setRow(0,0,u[0]); 67 lc.setRow(0,1,u[1]); 68 lc.setRow(0,2,u[2]); 69 lc.setRow(0,3,u[3]); 70 lc.setRow(0,4,u[4]); 71 delay(delaytime1); 72 lc.setRow(0,0,i[0]); 73 lc.setRow(0,1,i[1]); 74 lc.setRow(0,2,i[2]); 75 lc.setRow(0,3,i[3]); 76 lc.setRow(0,4,i[4]); 77 delay(delaytime1); 78 lc.setRow(0,0,n[0]); 79 lc.setRow(0,1,n[1]); 80 lc.setRow(0,2,n[2]); 81 lc.setRow(0,3,n[3]); 82 lc.setRow(0,4,n[4]); 83 delay(delaytime1); 84 lc.setRow(0,0,o[0]); 85 lc.setRow(0,1,o[1]); 86 lc.setRow(0,2,o[2]); 87 lc.setRow(0,3,o[3]); 88 lc.setRow(0,4,o[4]); 89 delay(delaytime1); 90 lc.setRow(0,0,0); 91 lc.setRow(0,1,0); 92 lc.setRow(0,2,0); 93 lc.setRow(0,3,0); 94 lc.setRow(0,4,0); 95 delay(delaytime1); 96} 97 98/* 99 This function lights up a some Leds in a row. 100 The pattern will be repeated on every row. 101 The pattern will blink along with the row-number. 102 row number 4 (index==3) will blink 4 times etc. 103 */ 104void rows() { 105 for(int row=0;row<8;row++) { 106 delay(delaytime2); 107 lc.setRow(0,row,B10100000); 108 delay(delaytime2); 109 lc.setRow(0,row,(byte)0); 110 for(int i=0;i<row;i++) { 111 delay(delaytime2); 112 lc.setRow(0,row,B10100000); 113 delay(delaytime2); 114 lc.setRow(0,row,(byte)0); 115 } 116 } 117} 118 119/* 120 This function lights up a some Leds in a column. 121 The pattern will be repeated on every column. 122 The pattern will blink along with the column-number. 123 column number 4 (index==3) will blink 4 times etc. 124 */ 125void columns() { 126 for(int col=0;col<8;col++) { 127 delay(delaytime2); 128 lc.setColumn(0,col,B00100000); 129 delay(delaytime2); 130 lc.setColumn(0,col,(byte)0); 131 for(int i=0;i<col;i++) { 132 delay(delaytime2); 133 lc.setColumn(0,col,B00100000); 134 delay(delaytime2); 135 lc.setColumn(0,col,(byte)0); 136 } 137 } 138} 139 140/* 141 This function will light up every Led on the matrix. 142 The led will blink along with the row-number. 143 row number 4 (index==3) will blink 4 times etc. 144 */ 145void single() { 146 for(int row=0;row<8;row++) { 147 for(int col=0;col<8;col++) { 148 delay(delaytime2); 149 lc.setLed(0,row,col,true); 150 delay(delaytime2); 151 for(int i=0;i<col;i++) { 152 lc.setLed(0,row,col,false); 153 delay(delaytime2); 154 lc.setLed(0,row,col,true); 155 delay(delaytime2); 156 } 157 } 158 } 159} 160 161void loop() { 162 writeArduinoOnMatrix(); 163 rows(); 164 columns(); 165 single(); 166} 167
Code
c_cpp
Copy/paste code
1//www.elegoo.com 2//2016.12.9 3 4//We always have to include the 5 library 6#include "LedControl.h" 7 8/* 9 Now we need a LedControl to work 10 with. 11 ***** These pin numbers will probably not work with your hardware ***** 12 13 pin 12 is connected to the DataIn 14 pin 11 is connected to LOAD(CS) 15 pin 10 16 is connected to the CLK 17 We have only a single MAX72XX. 18 */ 19LedControl 20 lc=LedControl(12,10,11,1); 21 22/* we always wait a bit between updates of the 23 display */ 24unsigned long delaytime1=500; 25unsigned long delaytime2=50; 26void 27 setup() { 28 /* 29 The MAX72XX is in power-saving mode on startup, 30 we 31 have to do a wakeup call 32 */ 33 lc.shutdown(0,false); 34 /* Set the brightness 35 to a medium values */ 36 lc.setIntensity(0,8); 37 /* and clear the display */ 38 39 lc.clearDisplay(0); 40} 41 42/* 43 This method will display the characters 44 for the 45 word "Arduino" one after the other on the matrix. 46 (you need at 47 least 5x7 leds to see the whole chars) 48 */ 49void writeArduinoOnMatrix() { 50 51 /* here is the data for the characters */ 52 byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110}; 53 54 byte r[5]={B00010000,B00100000,B00100000,B00010000,B00111110}; 55 byte d[5]={B11111110,B00010010,B00100010,B00100010,B00011100}; 56 57 byte u[5]={B00111110,B00000100,B00000010,B00000010,B00111100}; 58 byte i[5]={B00000000,B00000010,B10111110,B00100010,B00000000}; 59 60 byte n[5]={B00011110,B00100000,B00100000,B00010000,B00111110}; 61 byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100}; 62 63 64 /* now display them one by one with a small delay */ 65 lc.setRow(0,0,a[0]); 66 67 lc.setRow(0,1,a[1]); 68 lc.setRow(0,2,a[2]); 69 lc.setRow(0,3,a[3]); 70 lc.setRow(0,4,a[4]); 71 72 delay(delaytime1); 73 lc.setRow(0,0,r[0]); 74 lc.setRow(0,1,r[1]); 75 lc.setRow(0,2,r[2]); 76 77 lc.setRow(0,3,r[3]); 78 lc.setRow(0,4,r[4]); 79 delay(delaytime1); 80 lc.setRow(0,0,d[0]); 81 82 lc.setRow(0,1,d[1]); 83 lc.setRow(0,2,d[2]); 84 lc.setRow(0,3,d[3]); 85 lc.setRow(0,4,d[4]); 86 87 delay(delaytime1); 88 lc.setRow(0,0,u[0]); 89 lc.setRow(0,1,u[1]); 90 lc.setRow(0,2,u[2]); 91 92 lc.setRow(0,3,u[3]); 93 lc.setRow(0,4,u[4]); 94 delay(delaytime1); 95 lc.setRow(0,0,i[0]); 96 97 lc.setRow(0,1,i[1]); 98 lc.setRow(0,2,i[2]); 99 lc.setRow(0,3,i[3]); 100 lc.setRow(0,4,i[4]); 101 102 delay(delaytime1); 103 lc.setRow(0,0,n[0]); 104 lc.setRow(0,1,n[1]); 105 lc.setRow(0,2,n[2]); 106 107 lc.setRow(0,3,n[3]); 108 lc.setRow(0,4,n[4]); 109 delay(delaytime1); 110 lc.setRow(0,0,o[0]); 111 112 lc.setRow(0,1,o[1]); 113 lc.setRow(0,2,o[2]); 114 lc.setRow(0,3,o[3]); 115 lc.setRow(0,4,o[4]); 116 117 delay(delaytime1); 118 lc.setRow(0,0,0); 119 lc.setRow(0,1,0); 120 lc.setRow(0,2,0); 121 122 lc.setRow(0,3,0); 123 lc.setRow(0,4,0); 124 delay(delaytime1); 125} 126 127/* 128 129 This function lights up a some Leds in a row. 130 The pattern will be repeated 131 on every row. 132 The pattern will blink along with the row-number. 133 row number 134 4 (index==3) will blink 4 times etc. 135 */ 136void rows() { 137 for(int row=0;row<8;row++) 138 { 139 delay(delaytime2); 140 lc.setRow(0,row,B10100000); 141 delay(delaytime2); 142 143 lc.setRow(0,row,(byte)0); 144 for(int i=0;i<row;i++) { 145 delay(delaytime2); 146 147 lc.setRow(0,row,B10100000); 148 delay(delaytime2); 149 lc.setRow(0,row,(byte)0); 150 151 } 152 } 153} 154 155/* 156 This function lights up a some Leds in a column. 157 158 The pattern will be repeated on every column. 159 The pattern will blink along with 160 the column-number. 161 column number 4 (index==3) will blink 4 times etc. 162 */ 163void 164 columns() { 165 for(int col=0;col<8;col++) { 166 delay(delaytime2); 167 lc.setColumn(0,col,B00100000); 168 169 delay(delaytime2); 170 lc.setColumn(0,col,(byte)0); 171 for(int i=0;i<col;i++) 172 { 173 delay(delaytime2); 174 lc.setColumn(0,col,B00100000); 175 delay(delaytime2); 176 177 lc.setColumn(0,col,(byte)0); 178 } 179 } 180} 181 182/* 183 This function 184 will light up every Led on the matrix. 185 The led will blink along with the row-number. 186 187 row number 4 (index==3) will blink 4 times etc. 188 */ 189void single() { 190 for(int 191 row=0;row<8;row++) { 192 for(int col=0;col<8;col++) { 193 delay(delaytime2); 194 195 lc.setLed(0,row,col,true); 196 delay(delaytime2); 197 for(int i=0;i<col;i++) 198 { 199 lc.setLed(0,row,col,false); 200 delay(delaytime2); 201 lc.setLed(0,row,col,true); 202 203 delay(delaytime2); 204 } 205 } 206 } 207} 208 209void loop() { 210 211 writeArduinoOnMatrix(); 212 rows(); 213 columns(); 214 single(); 215} 216
Downloadable files
Arduino LED Matrix Schematic
Do the schematic
Arduino LED Matrix Schematic
Comments
Only logged in users can leave comments
arduinoman2
0 Followers
•0 Projects
Table of contents
Intro
1
0