//Pin definition decoder 7 segments (you can change the numbers if you wish ) const int bit_A = 2; const int bit_B = 3; const int bit_C = 4; const int bit_D = 5; // Pin definitions for each transistor display ( tens and units) const int alim_dizaine = 6; const int alim_unite = 7; void setup() { // The pins are all outputs pinMode(bit_A, OUTPUT); pinMode(bit_B, OUTPUT); pinMode(bit_C, OUTPUT); pinMode(bit_D, OUTPUT); pinMode(alim_dizaine, OUTPUT); pinMode(alim_unite, OUTPUT); // The pins are all set to the low state digitalWrite(bit_A, LOW); digitalWrite(bit_B, LOW); digitalWrite(bit_C, LOW); digitalWrite(bit_D, LOW); digitalWrite(alim_dizaine, LOW); digitalWrite(alim_unite, LOW); } void loop() //fonction principale { for(char i = 0; i<100; i++) // Loop that can count from 0 to 99 ( = 100 values) { afficher_nombre(i); // Call the function display with sending the number to be displayed } } // Function to display a number on both displays void afficher_nombre(char nombre) { long temps; // Variable used to determine the time elapsed ... char unite = 0, dizaine = 0; // Variable for each display if(nombre > 9) // If the received number exceeds 9 { dizaine = nombre / 10; // 10 recovering } unite = nombre - (dizaine*10); // Recovering units temps = millis(); // We retrieve the current time // So we have not shown the figure for at least 500 milliseconds // Allows to read the number displayed while((millis()-temps) < 500) { // Display the number // First the tens for 10 ms digitalWrite(alim_dizaine, HIGH); /* The transistor of the display dozens is saturated, So the display is lit*/ afficher(dizaine); // We call the function that displays the number ten digitalWrite(alim_unite, LOW); // The other transistor is off and the display off delay(10); // Then the units for 10 ms digitalWrite(alim_dizaine, LOW); // We turned off the transistor afficher(unite); // Call the function is used to display the unit number digitalWrite(alim_unite, HIGH); // And we light another delay(10); } } // Function writing on a single display // We use the same principle as seen above void afficher(char chiffre) { digitalWrite(bit_A, LOW); digitalWrite(bit_B, LOW); digitalWrite(bit_C, LOW); digitalWrite(bit_D, LOW); if(chiffre >= 8) { digitalWrite(bit_D, HIGH); chiffre = chiffre - 8; } if(chiffre >= 4) { digitalWrite(bit_C, HIGH); chiffre = chiffre - 4; } if(chiffre >= 2) { digitalWrite(bit_B, HIGH); chiffre = chiffre - 2; } if(chiffre >= 1) { digitalWrite(bit_A, HIGH); chiffre = chiffre - 1; } }