Étape 2: Code
int a = 2 ; Pour afficher le segment « a » et b int = 3 ; Pour afficher le segment « b »
int c = 4 ; Pour afficher le segment « c » int d = 5 ; Pour afficher le segment « d » int e = 6 ; Pour afficher le segment « e » int f = 8 ; Pour afficher le segment « f » int g = 9 ; Pour afficher le segment « g » void setup() {pinMode (a, sortie); //A pinMode (b, sortie); //B pinMode (c, sortie); //C pinMode (d, sortie); //D pinMode (e, sortie); //E pinMode (f, sortie); //F pinMode (g, sortie); //G} void displayDigit (int digit) {//Conditions pour l’affichage des segments a si (chiffre! = 1 & & chiffre! = 4) digitalWrite(a,HIGH) ; //Conditions pour afficher si le segment b (chiffre! = 5 & & chiffre! = 6) digitalWrite (b ÉLEVÉ) ; Conditions d’affichage de segment c si (chiffre! = 2) digitalWrite(c,HIGH) ; Conditions d’affichage d segment si (chiffre! = 1 & & chiffre! = 4 & & chiffre! = 7) digitalWrite(d,HIGH) ; Conditions d’affichage de segment e si (chiffre == 2 || chiffre == 6 || chiffre == 8 || chiffre == 0) digitalWrite(e,HIGH) ; Conditions d’affichage segment f si (chiffre! = 1 & & chiffre! = 2 & & chiffre! = 3 & & chiffre! = 7) digitalWrite(f,HIGH) ; Si (chiffre! = 0 & & chiffre! = 1 & & chiffre! = 7) digitalWrite(g,HIGH) ; } void turnOff() {digitalWrite(a,LOW) ; digitalWrite(b,LOW) ; digitalWrite(c,LOW) ; digitalWrite(d,LOW) ; digitalWrite(e,LOW) ; digitalWrite(f,LOW) ; digitalWrite(g,LOW);}
void loop() {pour (int i = 0; i < 10; i ++) {displayDigit(i) ; delay(1000) ; turnOff();}}