Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---Variables---
- int BoutonMoins = 2;
- int BoutonPlus = 3;
- int Pin[5] = {6,7,8,9,10};
- int NbrActuel = 0;
- int NbrAffiche = 0;
- void Affichage(int nombre);
- //---Initialisation---
- void setup()
- {
- pinMode(11,OUTPUT);
- pinMode(12,OUTPUT);
- Serial.begin(9600);
- pinMode(BoutonMoins,INPUT_PULLUP);
- pinMode(BoutonPlus,INPUT_PULLUP);
- for (int i=0;i<=4;i++)
- {
- pinMode(Pin[i],OUTPUT);
- }
- Serial.println("---Initialisation Terminer---");
- Serial.println("Appuyer sur un des deux bouton !");
- }
- // ---Debut Programme Principale---
- void loop()
- {
- boolean EtatBoutonMoins = digitalRead(BoutonMoins);
- boolean EtatBoutonPlus = digitalRead(BoutonPlus);
- if (!EtatBoutonMoins == HIGH)
- {
- if (NbrActuel > 0)
- {
- Serial.println("---Bouton - Activer!---");
- NbrActuel = NbrActuel - 1;
- digitalWrite(12,HIGH);
- Affichage(NbrActuel);
- delay(1800);
- digitalWrite(12,LOW);
- }
- }
- if (!EtatBoutonPlus == HIGH)
- {
- if (NbrActuel < 5)
- {
- Serial.println("---Bouton + Activer!---");
- NbrActuel = NbrActuel + 1;
- digitalWrite(11,HIGH);
- Affichage(NbrActuel);
- delay(800);
- digitalWrite(11,LOW);
- }
- }
- if (!EtatBoutonPlus && !EtatBoutonMoins == HIGH)
- {
- Serial.println("---Remise a zero---");
- Affichage(0);
- }
- delay (100);
- }
- //---Debut Fonctions---
- void Affichage(int nombre)
- {
- if (nombre > NbrAffiche )
- {
- for (int j=0;j<nombre;j++)
- {
- digitalWrite(Pin[j],HIGH);
- }
- NbrAffiche = NbrActuel;
- Serial.print("Nombre actuellement afficher :");
- Serial.println(NbrAffiche);
- }
- if (nombre < NbrAffiche)
- {
- for (int h=5;h>=nombre;h--)
- {
- digitalWrite(Pin[h],LOW);
- }
- NbrAffiche = NbrActuel;
- Serial.print("Nombre actuellement afficher :");
- Serial.println(NbrAffiche);
- }
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement