Yet another illustration guide, how to wire the MAX7219 on 8 Bit 7 Segment Digital LED Display driven by MAX7219. The MAX7219 is an integrated serial input output common-cathode display driver which is connected to microprocessor or microcontroller along with
Starter #10 Driving 7 Segment Digital Display with Arduino with Source Code
Here the steps how to wire and driving the 7 segment digital display using Arduino. Electronic Parts Required ARDUINO UNO/MEGA/PRO 4x Seven Segment Digital Display 8x 220 k Resistor
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
/* . . ........ .... .. ...... ........ MMMM MMMMM MMMMMMMMMMMMMMMMMMM MMMMMMMMMM. MMMMMMMMM MMM.MMMMMMM MMM MMM .MM.MMM MMM ......... .... ... . . . MMM MMMMMMM . .MM. MM. MMM MM. . MMM MMMMMMMMM MMMM MMMMM.MM MM MMMMMMMMMMMM. .MMM MMM. .MMM.MMMMMMMMM ........ MMM MM . M .MMMMMMMM. MMM .MMM MMMMMMMM.MMMMMMM. MM .MMM. MMMMMMMM. MMM .MMMM MMMM MMMMMM. www.14core.com . ... . . ...... */ int a = 1; int b = 2; int c = 3; int d = 4; int e = 5; int f = 6; int g = 7; int p = 8; int d4 = 9; int d3 = 10; int d2 = 11; int d1 = 12; long n = 0; int x = 100; int del = 55; void setup() { pinMode(d1, OUTPUT); pinMode(d2, OUTPUT); pinMode(d3, OUTPUT); pinMode(d4, OUTPUT); pinMode(a, OUTPUT); pinMode(b, OUTPUT); pinMode(c, OUTPUT); pinMode(d, OUTPUT); pinMode(e, OUTPUT); pinMode(f, OUTPUT); pinMode(g, OUTPUT); pinMode(p, OUTPUT); pinMode(13,INPUT); } void loop() { clearLEDs(); pickDigit(1); pickNumber((n/x/1000)%10); delayMicroseconds(del); clearLEDs(); pickDigit(2); pickNumber((n/x/100)%10); delayMicroseconds(del); clearLEDs(); pickDigit(3); dispDec(3); pickNumber((n/x/10)%10); delayMicroseconds(del); clearLEDs(); pickDigit(4); pickNumber(n/x%10); delayMicroseconds(del); n++; /* When you need to put the numbers to zero, you may use this function ClearDigital(); */ //ClearDigital(); } void pickDigit(int x) { digitalWrite(d1, HIGH); digitalWrite(d2, HIGH); digitalWrite(d3, HIGH); digitalWrite(d4, HIGH); switch(x) { case 1: digitalWrite(d1, LOW); break; case 2: digitalWrite(d2, LOW); break; case 3: digitalWrite(d3, LOW); break; default: digitalWrite(d4, LOW); break; } } void pickNumber(int x) { switch(x) { default: zero(); break; case 1: one(); break; case 2: two(); break; case 3: three(); break; case 4: four(); break; case 5: five(); break; case 6: six(); break; case 7: seven(); break; case 8: eight(); break; case 9: nine(); break; } } void dispDec(int x) { digitalWrite(p, LOW); } void clearLEDs() { digitalWrite(a, LOW); digitalWrite(b, LOW); digitalWrite(c, LOW); digitalWrite(d, LOW); digitalWrite(e, LOW); digitalWrite(f, LOW); digitalWrite(g, LOW); digitalWrite(p, LOW); } void zero() { digitalWrite(a, HIGH); digitalWrite(b, HIGH); digitalWrite(c, HIGH); digitalWrite(d, HIGH); digitalWrite(e, HIGH); digitalWrite(f, HIGH); digitalWrite(g, LOW); } void one() { digitalWrite(a, LOW); digitalWrite(b, HIGH); digitalWrite(c, HIGH); digitalWrite(d, LOW); digitalWrite(e, LOW); digitalWrite(f, LOW); digitalWrite(g, LOW); } void two() { digitalWrite(a, HIGH); digitalWrite(b, HIGH); digitalWrite(c, LOW); digitalWrite(d, HIGH); digitalWrite(e, HIGH); digitalWrite(f, LOW); digitalWrite(g, HIGH); } void three() { digitalWrite(a, HIGH); digitalWrite(b, HIGH); digitalWrite(c, HIGH); digitalWrite(d, HIGH); digitalWrite(e, LOW); digitalWrite(f, LOW); digitalWrite(g, HIGH); } void four() { digitalWrite(a, LOW); digitalWrite(b, HIGH); digitalWrite(c, HIGH); digitalWrite(d, LOW); digitalWrite(e, LOW); digitalWrite(f, HIGH); digitalWrite(g, HIGH); } void five() { digitalWrite(a, HIGH); digitalWrite(b, LOW); digitalWrite(c, HIGH); digitalWrite(d, HIGH); digitalWrite(e, LOW); digitalWrite(f, HIGH); digitalWrite(g, HIGH); } void six() { digitalWrite(a, HIGH); digitalWrite(b, LOW); digitalWrite(c, HIGH); digitalWrite(d, HIGH); digitalWrite(e, HIGH); digitalWrite(f, HIGH); digitalWrite(g, HIGH); } void seven() { digitalWrite(a, HIGH); digitalWrite(b, HIGH); digitalWrite(c, HIGH); digitalWrite(d, LOW); digitalWrite(e, LOW); digitalWrite(f, LOW); digitalWrite(g, LOW); } void eight() { digitalWrite(a, HIGH); digitalWrite(b, HIGH); digitalWrite(c, HIGH); digitalWrite(d, HIGH); digitalWrite(e, HIGH); digitalWrite(f, HIGH); digitalWrite(g, HIGH); } void nine() { digitalWrite(a, HIGH); digitalWrite(b, HIGH); digitalWrite(c, HIGH); digitalWrite(d, HIGH); digitalWrite(e, LOW); digitalWrite(f, HIGH); digitalWrite(g, HIGH); } /* you can add a button, please refer to 14Core Starter #3 Button Control. keep the Pin13 all high. when push the button, it become LOW. n=0; */ void ClearDigital() { if(digitalRead(13)== LOW) { n=0; } } |
Download the source code here | 14Core Digital Display