// Déclaration et initialisation des segments
int a = 2;
int b = 0;
int c = 4;
int d = 5;
int e = 15;
int f = 34;
int g = 17;
// Table de vérité des segments pour chaque chiffre (a, b, c, d, e, f, g)
int segments[10][7] = {
{1, 1, 1, 1, 1, 1, 0}, // 0
{0, 1, 1, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1}, // 2
{1, 1, 1, 1, 0, 0, 1}, // 3
{0, 1, 1, 0, 0, 1, 1}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 0, 1, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1}, // 8
{1, 1, 1, 1, 0, 1, 1} // 9
};
// Tableau des pins dans l'ordre a, b, c, d, e, f, g
int pins[7] = {a, b, c, d, e, f, g};
void afficherChiffre(int chiffre) {
// Activer/désactiver chaque segment selon la table
for (int i = 0; i < 7; i++) {
digitalWrite(pins[i], segments[chiffre][i]);
}
}
void setup() {
// Configurer tous les segments comme sorties
for (int i = 0; i < 7; i++) {
pinMode(pins[i], OUTPUT);
}
Serial.begin(9600);
}
void loop() {
// Afficher les chiffres de 0 à 9
for (int chiffre = 0; chiffre <= 9; chiffre++) {
afficherChiffre(chiffre);
Serial.print("Affichage : ");
Serial.println(chiffre);
delay(1000);
}
}