Présentation
Cette petite carte prototype d’environ 10x10cm permet d’accueillir une carte Arduino UNO et de disposer de quatre boutons poussoirs, d’un afficheur de 4 digits de 7 segments, de 2 relais, et d’une Led rouge.
Elle permet de réaliser de multiples développements expérimentaux, en commençant par exemple, par un simple chronomètre…
Deux principales difficultés : La réalisation des soudures qui doivent être très soignées ! Et, pour la partie développement, la gestion de l’afficheur 4 digits qui est directement relié à l’Arduino, sans aucun circuit de gestion.
Je vous propose de décrire, en quelques lignes, les différentes étapes de cette réalisation, et plus particulièrement le schéma et un exemple de code.
Liste des pièces
- 4 Boutons poussoirs
- 1 afficheur 7 Segments, 4 digits
- 2 Borniers pour CI
- 2 transistor 2N2222 et quelques résistances … (voir le schéma)
Schéma
Rien de compliqué ! Il faut juste veiller à câbler l’afficheur correctement :
Attention : Selon le modèle utilisé, l’afficheur 4 x 7 segments peut avoir l’Anode et la Cathode de toutes ces diodes inversées !
Mais cela ne change rien au câblage, il faudra juste inverser la logique de programmation dans les définitions des numéros.
Voici le schéma global :
Les soudures vues de prêt
Un bon fer à souder, de la soudure et des fils adaptés …. et un peu de patience :
Exemple de développement
OK ! je rajoute bientôt quelques explications ….
Le code
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 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
// -------------------- Cablage int Aff_A = 2; int Aff_B = 0; int Aff_C = 6; int Aff_D = 4; int Aff_E = 3; int Aff_F = 1; int Aff_G = 5; int Aff_1 = 9; int Aff_2 = 8; int Aff_3 = 7; int Aff_4 = 10; int Relais_1 = 11; int Relais_2 = 12; int led = 13; int Sw_1 = A2; int Sw_2 = A3; int Sw_3 = A0; int Sw_4 = A1; // -------------------- Variables boolean led_status = false; int a = 0; int val = 21; int val_set = val; int millieme; int centaine; int dizaine; int unite; int Val_sw1; int Val_sw2; int Val_sw3; int Val_sw4; unsigned long time; unsigned long sw1_push_time; unsigned long sw2_push_time; unsigned long sw3_push_time; unsigned long sw4_push_time; unsigned long chrono_time; boolean intro = true; int temp = 100; boolean Chrono = false; boolean Commande = false; void setup () { pinMode(led, OUTPUT); pinMode(Relais_1, OUTPUT); pinMode(Relais_2, OUTPUT); pinMode(Aff_A, OUTPUT); pinMode(Aff_B, OUTPUT); pinMode(Aff_C, OUTPUT); pinMode(Aff_D, OUTPUT); pinMode(Aff_E, OUTPUT); pinMode(Aff_F, OUTPUT); pinMode(Aff_G, OUTPUT); pinMode(Aff_1, OUTPUT); pinMode(Aff_2, OUTPUT); pinMode(Aff_3, OUTPUT); pinMode(Aff_4, OUTPUT); time = millis(); } void loop () { // Intro if (intro == true) { digitalWrite(led, HIGH); digitalWrite(Aff_G, HIGH); delay (temp); digitalWrite(Aff_G, LOW); digitalWrite(Aff_F, HIGH); delay (temp); digitalWrite(Aff_F, LOW); digitalWrite(Aff_A, HIGH); delay (temp); digitalWrite(Aff_A, LOW); digitalWrite(Aff_B, HIGH); delay (temp); digitalWrite(Aff_B, LOW); digitalWrite(Aff_G, HIGH); delay (temp); digitalWrite(Aff_G, LOW); digitalWrite(Aff_E, HIGH); delay (temp); digitalWrite(Aff_E, LOW); digitalWrite(Aff_D, HIGH); delay (temp); digitalWrite(Aff_D, LOW); digitalWrite(Aff_C, HIGH); delay (temp); digitalWrite(Aff_C, LOW); digitalWrite(led, LOW); intro = false; } // ----------------------------- BOUTTONS ---------------------------- Val_sw1 = analogRead (Sw_1) ; Val_sw2 = analogRead (Sw_2) ; Val_sw3 = analogRead (Sw_3) ; Val_sw4 = analogRead (Sw_4) ; // traitement switch 1 - PLUS if ( Val_sw1 < 10 && val < 9999 && millis() > sw1_push_time + 100 && Chrono == false ) { sw1_push_time = millis(); val++; val_set = val; } // traitement switch 2 - MOINS if ( Val_sw2 < 10 && val > 0 && millis() > sw2_push_time + 100 && Chrono == false ) { sw2_push_time = millis(); val--; val_set = val; } // traitement switch 3 - STOP if ( Val_sw3 < 10 && millis() > sw3_push_time + 1000) { sw3_push_time = millis(); if ( Commande == true ) { Chrono = false; Commande = false; val = val_set; } else { Commande = true; } } // traitement switch 4 - START if ( Val_sw4 < 10 && Chrono != true) { Chrono = true; chrono_time = millis(); Commande = true; val_set = val; } // ---------------------------- CHRONO ------------------------------ if ( Chrono == true && millis() >= chrono_time + 1000 ) { val--; chrono_time = millis(); if ( val == 0 ) { Chrono = false; Commande = false; val = val_set; } } // ---------------------------- SORTIE ---------------------------- if ( Commande == true ) { digitalWrite(led, HIGH); // digitalWrite(Relais_1, HIGH); } else { digitalWrite(led, LOW); // digitalWrite(Relais_1, LOW); } // ---------------------------- AFFICHAGE ---------------------------- millieme = val/1000; centaine = (val - millieme*1000)/100; dizaine = (val - millieme*1000 - centaine*100)/10; unite = (val - millieme*1000 - centaine*100 - dizaine*10); pickDigit(4); pickNumber(unite); pickDigit(3); pickNumber(dizaine); pickDigit(2); pickNumber(centaine); pickDigit(1); pickNumber(millieme); clearLEDs (); } void pickDigit (int x) { clearLEDs (); switch (x) { case 1: digitalWrite (Aff_1, LOW); break; case 2: digitalWrite (Aff_2, LOW); break; case 3: digitalWrite (Aff_3, LOW); break; case 4: digitalWrite (Aff_4, LOW); break; } } void pickNumber (int x) // define pickNumber (x), whose role is to show digital x- { switch (x) { case 0: 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 clearLEDs () // clear the screen { digitalWrite (Aff_A, LOW); digitalWrite (Aff_B, LOW); digitalWrite (Aff_C, LOW); digitalWrite (Aff_D, LOW); digitalWrite (Aff_E, LOW); digitalWrite (Aff_F, LOW); digitalWrite (Aff_G, LOW); digitalWrite (Aff_1, HIGH); digitalWrite (Aff_2, HIGH); digitalWrite (Aff_3, HIGH); digitalWrite (Aff_4, HIGH); } void zero () // define those figures 0:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, HIGH); digitalWrite (Aff_E, HIGH); digitalWrite (Aff_F, HIGH); digitalWrite (Aff_G, LOW); } void one () // define those figures 1:00 cathode pin switch { digitalWrite (Aff_A, LOW); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, LOW); digitalWrite (Aff_E, LOW); digitalWrite (Aff_F, LOW); digitalWrite (Aff_G, LOW); } void two () // define those figures 2:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, LOW); digitalWrite (Aff_D, HIGH); digitalWrite (Aff_E, HIGH); digitalWrite (Aff_F, LOW); digitalWrite (Aff_G, HIGH); } void three () // define those figures 3:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, HIGH); digitalWrite (Aff_E, LOW); digitalWrite (Aff_F, LOW); digitalWrite (Aff_G, HIGH); } void four () // define those figures 4:00 cathode pin switch { digitalWrite (Aff_A, LOW); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, LOW); digitalWrite (Aff_E, LOW); digitalWrite (Aff_F, HIGH); digitalWrite (Aff_G, HIGH); } void five () // define those figures 5:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, LOW); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, HIGH); digitalWrite (Aff_E, LOW); digitalWrite (Aff_F, HIGH); digitalWrite (Aff_G, HIGH); } void six () // define those figures 6:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, LOW); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, HIGH); digitalWrite (Aff_E, HIGH); digitalWrite (Aff_F, HIGH); digitalWrite (Aff_G, HIGH); } void seven () // define those figures 7:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, LOW); digitalWrite (Aff_E, LOW); digitalWrite (Aff_F, LOW); digitalWrite (Aff_G, LOW); } void eight () // define those figures 8:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, HIGH); digitalWrite (Aff_E, HIGH); digitalWrite (Aff_F, HIGH); digitalWrite (Aff_G, HIGH); } void nine () // define those figures 9:00 cathode pin switch { digitalWrite (Aff_A, HIGH); digitalWrite (Aff_B, HIGH); digitalWrite (Aff_C, HIGH); digitalWrite (Aff_D, HIGH); digitalWrite (Aff_E, LOW); digitalWrite (Aff_F, HIGH); digitalWrite (Aff_G, HIGH); } |