Afficheur 7 segment de 0 à 9
int seg1=1,seg2=2,seg3=3, seg4=4, seg5=5, seg6=6, seg7=7;
void setup() {
for(int x=0; x <=7; x++)
{
pinMode(x, OUTPUT);
}
}
void loop()
{
digitalWrite(seg1, HIGH); // chiffre 0
digitalWrite(seg2, HIGH);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, HIGH);
digitalWrite(seg7, LOW);
delay(1000);
digitalWrite(seg1, LOW); // chiffre 1
digitalWrite(seg2, LOW);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, LOW);
digitalWrite(seg6, LOW);
digitalWrite(seg7, LOW);
delay(1000);
digitalWrite(seg1, HIGH); //chiffre 2
digitalWrite(seg2, HIGH);
digitalWrite(seg3, LOW);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, LOW);
digitalWrite(seg7, HIGH);
delay(1000);
digitalWrite(seg1, LOW); //chiffre 3
digitalWrite(seg2, HIGH);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, LOW);
digitalWrite(seg7, HIGH);
delay(1000);
digitalWrite(seg1, LOW); //chiffre 4
digitalWrite(seg2, LOW);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, LOW);
digitalWrite(seg6, HIGH);
digitalWrite(seg7, HIGH);
delay(1000);
digitalWrite(seg1, LOW); //chiffre 5
digitalWrite(seg2, HIGH);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, LOW);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, HIGH);
digitalWrite(seg7, HIGH);
delay(1000);
digitalWrite(seg1, HIGH); //chiffre 6
digitalWrite(seg2, HIGH);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, LOW);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, HIGH);
digitalWrite(seg7, HIGH);
delay(1000);
digitalWrite(seg1, LOW); //chiffre 7
digitalWrite(seg2, LOW);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, LOW);
digitalWrite(seg7, LOW);
delay(1000);
digitalWrite(seg1, HIGH); //chiffre 8
digitalWrite(seg2, HIGH);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, HIGH);
digitalWrite(seg7, HIGH);
delay(1000);
digitalWrite(seg1, LOW); //chiffre 9
digitalWrite(seg2, HIGH);
digitalWrite(seg3, HIGH);
digitalWrite(seg4, HIGH);
digitalWrite(seg5, HIGH);
digitalWrite(seg6, HIGH);
digitalWrite(seg7, HIGH);
delay(1000);
}
Explication: Le programme va afficher les chiffres de 0 à 9 en boucle.