// Appel de la bibliothèque TM1637
#include <TM1637Display.h>
// Nommage des broches
#define CLK 3
#define DIO 2
#define pinBouton1 4
#define pinBouton2 5
// Déclaration de l'afficheur
TM1637Display afficheur(CLK, DIO);
// Initialisation des compteurs
int compteur1 = 0;
int compteur2 = 0;
void setup() {
// Déclaration des broches des boutons en entrée "pull-up"
pinMode(pinBouton1, INPUT_PULLUP);
pinMode(pinBouton2, INPUT_PULLUP);
// Réglage de la luminosité de l'afficheur
afficheur.setBrightness(7);
}
void loop() {
// Test du bouton 1 (appuyé = LOW)
if(digitalRead(pinBouton1)==LOW){
compteur1++;
// on attend que le bouton soit relaché
while(digitalRead(pinBouton1)==LOW) {
// on attend
}
}
// Test du bouton 1 (appuyé = LOW)
if(digitalRead(pinBouton2)==LOW){
compteur2++;
// on attend que le bouton soit relaché
while(digitalRead(pinBouton2)==LOW) {
// on attend
}
}
// Affichage compteur 1 à gauche
afficheur.showNumberDecEx(compteur1,0b01000000, true, 2, 0);
// Affichage compteur 2 à droite
afficheur.showNumberDecEx(compteur2,0b01000000, true, 2, 2);
}