#include <TM1637.h>
const int CLK = 6;
const int DIO = 7;
TM1637 tm(CLK, DIO);
const int buttonPin = 2;
int buttonState = 0;
void setup() {
tm.init();
tm.set(BRIGHT_TYPICAL);
pinMode(buttonPin, INPUT);
Serial.begin(9600);
}
unsigned int counter = 0;
void loop() {
buttonState = digitalRead(buttonPin);
tm.display(0, (counter / 1000) % 10);
tm.display(1, (counter / 100) % 10);
tm.display(2, (counter / 10) % 10);
tm.display(3, counter % 10);
if (counter == 10000) {
counter = 0;
}
delay(120);
if (buttonState == HIGH) {
counter++;
}
Serial.println(counter);
}