Components and supplies
Arduino UNO
Resistor 1k ohm
Solderless Breadboard Full Size
7 Segment LED Display, InfoVue
Jumper wires (generic)
Apps and platforms
Arduino IDE
Project description
Code
0-9 Counter using Arduino & 5611AH 7-segment display
arduino
Just paste this code in the arduino editor and compile it before flashing it on your arduino uno.
1/* 2 Displays the numbers 0-9 on the display, at one second intervals 3 Implemented using 5611AH - 8-segment display 4 Pin assignment for 5611AH 5 G F com A B 6 __|__|__|__|__|__ 7 | 10 9 8 7 6 | 8 | 1 2 3 4 5 | 9 --|--|--|--|--|-- 10 E D com C P 11 12 A=7,B=6,C=4,D=2,E=1,F=9,G=10,P=5,com=GND 13 LED segment assignment corresponding to pins 14 A 15 --- 16F | | B 17 | G | 18 --- 19E | | C 20 | | 21 --- . P 22 D 23*/ 24 25// Pin 2-8 is connected to the 7 segments of the display. 26 27int pinA = 8; 28int pinB = 9; 29int pinC = 4; 30int pinD = 3; 31int pinE = 2; 32int pinF = 7; 33int pinG = 6; 34int pinP = 5; 35 36/* 37int D1 = 10; 38int D2 = 11; 39int D3 = 12; 40int D4 = 13; 41*/ 42 43void setup() { 44// initialize the digital pins as outputs. 45 pinMode(pinA, OUTPUT); 46 pinMode(pinB, OUTPUT); 47 pinMode(pinC, OUTPUT); 48 pinMode(pinD, OUTPUT); 49 pinMode(pinE, OUTPUT); 50 pinMode(pinF, OUTPUT); 51 pinMode(pinG, OUTPUT); 52 pinMode(pinP, OUTPUT); 53/* 54 pinMode(D1, OUTPUT); 55 pinMode(D2, OUTPUT); 56 pinMode(D3, OUTPUT); 57 pinMode(D4, OUTPUT); 58*/ 59} 60 61void loop() { 62//0 63 digitalWrite(pinA, HIGH); 64 digitalWrite(pinB, HIGH); 65 digitalWrite(pinC, HIGH); 66 digitalWrite(pinD, HIGH); 67 digitalWrite(pinE, HIGH); 68 digitalWrite(pinF, HIGH); 69 digitalWrite(pinG, LOW); 70 digitalWrite(pinP, LOW); 71 delay(500); // wait for a second 72 73 digitalWrite(pinA, HIGH); 74 digitalWrite(pinB, HIGH); 75 digitalWrite(pinC, HIGH); 76 digitalWrite(pinD, HIGH); 77 digitalWrite(pinE, HIGH); 78 digitalWrite(pinF, HIGH); 79 digitalWrite(pinG, LOW); 80 digitalWrite(pinP, HIGH); 81 delay(500); 82 83//1 84 digitalWrite(pinA, LOW); 85 digitalWrite(pinB, HIGH); 86 digitalWrite(pinC, HIGH); 87 digitalWrite(pinD, LOW); 88 digitalWrite(pinE, LOW); 89 digitalWrite(pinF, LOW); 90 digitalWrite(pinG, LOW); 91 digitalWrite(pinP, LOW); 92 delay(500); // wait for a second 93 94 digitalWrite(pinA, LOW); 95 digitalWrite(pinB, HIGH); 96 digitalWrite(pinC, HIGH); 97 digitalWrite(pinD, LOW); 98 digitalWrite(pinE, LOW); 99 digitalWrite(pinF, LOW); 100 digitalWrite(pinG, LOW); 101 digitalWrite(pinP, HIGH); 102 delay(500); 103 104//2 105 digitalWrite(pinA, HIGH); 106 digitalWrite(pinB, HIGH); 107 digitalWrite(pinC, LOW); 108 digitalWrite(pinD, HIGH); 109 digitalWrite(pinE, HIGH); 110 digitalWrite(pinF, LOW); 111 digitalWrite(pinG, HIGH); 112 digitalWrite(pinP, LOW); 113 delay(500); // wait for a second 114 115 digitalWrite(pinA, HIGH); 116 digitalWrite(pinB, HIGH); 117 digitalWrite(pinC, LOW); 118 digitalWrite(pinD, HIGH); 119 digitalWrite(pinE, HIGH); 120 digitalWrite(pinF, LOW); 121 digitalWrite(pinG, HIGH); 122 digitalWrite(pinP, HIGH); 123 delay(500); 124 125//3 126 digitalWrite(pinA, HIGH); 127 digitalWrite(pinB, HIGH); 128 digitalWrite(pinC, HIGH); 129 digitalWrite(pinD, HIGH); 130 digitalWrite(pinE, LOW); 131 digitalWrite(pinF, LOW); 132 digitalWrite(pinG, HIGH); 133 digitalWrite(pinP, LOW); 134 delay(500); // wait for a second 135 136 digitalWrite(pinA, HIGH); 137 digitalWrite(pinB, HIGH); 138 digitalWrite(pinC, HIGH); 139 digitalWrite(pinD, HIGH); 140 digitalWrite(pinE, LOW); 141 digitalWrite(pinF, LOW); 142 digitalWrite(pinG, HIGH); 143 digitalWrite(pinP, HIGH); 144 delay(500); 145 146//4 147 digitalWrite(pinA, LOW); 148 digitalWrite(pinB, HIGH); 149 digitalWrite(pinC, HIGH); 150 digitalWrite(pinD, LOW); 151 digitalWrite(pinE, LOW); 152 digitalWrite(pinF, HIGH); 153 digitalWrite(pinG, HIGH); 154 digitalWrite(pinP, LOW); 155 delay(500); // wait for a second 156 157 digitalWrite(pinA, LOW); 158 digitalWrite(pinB, HIGH); 159 digitalWrite(pinC, HIGH); 160 digitalWrite(pinD, LOW); 161 digitalWrite(pinE, LOW); 162 digitalWrite(pinF, HIGH); 163 digitalWrite(pinG, HIGH); 164 digitalWrite(pinP, HIGH); 165 delay(500); 166 167//5 168 digitalWrite(pinA, HIGH); 169 digitalWrite(pinB, LOW); 170 digitalWrite(pinC, HIGH); 171 digitalWrite(pinD, HIGH); 172 digitalWrite(pinE, LOW); 173 digitalWrite(pinF, HIGH); 174 digitalWrite(pinG, HIGH); 175 digitalWrite(pinP, LOW); 176 delay(500); // wait for a second 177 178 digitalWrite(pinA, HIGH); 179 digitalWrite(pinB, LOW); 180 digitalWrite(pinC, HIGH); 181 digitalWrite(pinD, HIGH); 182 digitalWrite(pinE, LOW); 183 digitalWrite(pinF, HIGH); 184 digitalWrite(pinG, HIGH); 185 digitalWrite(pinP, HIGH); 186 delay(500); 187 188//6 189 digitalWrite(pinA, HIGH); 190 digitalWrite(pinB, LOW); 191 digitalWrite(pinC, HIGH); 192 digitalWrite(pinD, HIGH); 193 digitalWrite(pinE, HIGH); 194 digitalWrite(pinF, HIGH); 195 digitalWrite(pinG, HIGH); 196 digitalWrite(pinP, LOW); 197 delay(500); // wait for a second 198 199 digitalWrite(pinA, HIGH); 200 digitalWrite(pinB, LOW); 201 digitalWrite(pinC, HIGH); 202 digitalWrite(pinD, HIGH); 203 digitalWrite(pinE, HIGH); 204 digitalWrite(pinF, HIGH); 205 digitalWrite(pinG, HIGH); 206 digitalWrite(pinP, HIGH); 207 delay(500); 208 209//7 210 digitalWrite(pinA, HIGH); 211 digitalWrite(pinB, HIGH); 212 digitalWrite(pinC, HIGH); 213 digitalWrite(pinD, LOW); 214 digitalWrite(pinE, LOW); 215 digitalWrite(pinF, LOW); 216 digitalWrite(pinG, LOW); 217 digitalWrite(pinP, LOW); 218 delay(500); // wait for a second 219 220 digitalWrite(pinA, HIGH); 221 digitalWrite(pinB, HIGH); 222 digitalWrite(pinC, HIGH); 223 digitalWrite(pinD, LOW); 224 digitalWrite(pinE, LOW); 225 digitalWrite(pinF, LOW); 226 digitalWrite(pinG, LOW); 227 digitalWrite(pinP, HIGH); 228 delay(500); 229 230//8 231 digitalWrite(pinA, HIGH); 232 digitalWrite(pinB, HIGH); 233 digitalWrite(pinC, HIGH); 234 digitalWrite(pinD, HIGH); 235 digitalWrite(pinE, HIGH); 236 digitalWrite(pinF, HIGH); 237 digitalWrite(pinG, HIGH); 238 digitalWrite(pinP, LOW); 239 delay(500); // wait for a second 240 241 digitalWrite(pinA, HIGH); 242 digitalWrite(pinB, HIGH); 243 digitalWrite(pinC, HIGH); 244 digitalWrite(pinD, HIGH); 245 digitalWrite(pinE, HIGH); 246 digitalWrite(pinF, HIGH); 247 digitalWrite(pinG, HIGH); 248 digitalWrite(pinP, HIGH); 249 delay(500); 250 251//9 252 digitalWrite(pinA, HIGH); 253 digitalWrite(pinB, HIGH); 254 digitalWrite(pinC, HIGH); 255 digitalWrite(pinD, HIGH); 256 digitalWrite(pinE, LOW); 257 digitalWrite(pinF, HIGH); 258 digitalWrite(pinG, HIGH); 259 digitalWrite(pinP, LOW); 260 delay(500); // wait for a second 261 262 digitalWrite(pinA, HIGH); 263 digitalWrite(pinB, HIGH); 264 digitalWrite(pinC, HIGH); 265 digitalWrite(pinD, HIGH); 266 digitalWrite(pinE, LOW); 267 digitalWrite(pinF, HIGH); 268 digitalWrite(pinG, HIGH); 269 digitalWrite(pinP, HIGH); 270 delay(500); 271 272}
Downloadable files
Circuit connection diagram
Designed using Fritzing
Circuit connection diagram
Connection diagram
Connection diagram
Connection diagram
Connection diagram
Circuit connection diagram
Designed using Fritzing
Circuit connection diagram
Comments
Only logged in users can leave comments
Anonymous user
2 years ago
He has the pins all wrong. Heres the correct pins- PinA - 8 PinB - 9 PinC - 4 PinD - 3 PinE - 2 PinF - 7 PinG - 6 You dont need PinP since its the dot, just modify it a bit
Anonymous user
3 years ago
When I tried out this project, the 7-segment led display (one digit) only showed incompleted numbers in the wrong order. Could you please look into this?