#define DATA_PIN 2
#define CLOCK_PIN 3
#define LATCH_PIN 4
#define BUTTON_PIN 5

byte segments[10] = {
  0b01111101, 0b00100100, 0b01111010, 0b01110110, 0b00100111,
  0b01010111, 0b01011111, 0b01100100, 0b01111111, 0b01110111
};

int clicks = 0;
boolean buttonWasUp = true;

void setup() {
  pinMode(DATA_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);
  pinMode(LATCH_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop() {
  boolean buttonIsUp = digitalRead(BUTTON_PIN);
  if (buttonWasUp && !buttonIsUp) {
    delay(10);
    buttonIsUp = digitalRead(BUTTON_PIN);
    if (!buttonIsUp) {
      clicks = (clicks + 1) % 10;
      buttonWasUp = false;
    }
  }
  buttonWasUp = buttonIsUp;

  digitalWrite(LATCH_PIN, LOW);
  shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, segments[clicks]);
  digitalWrite(LATCH_PIN, HIGH);
}
74HC595