#include "SevSeg.h"

#define SW_START  12
#define BUZZER    11

int counter = 0;

SevSeg sevseg;  // Seven segment object

void setup() {

  pinMode(SW_START, INPUT_PULLUP);
  pinMode(BUZZER, OUTPUT);

  byte numDigits = 1; // Set to 1 for single-digit display

  // Defines common pins while using multi-digit display. 
  // Left for single digit display
  byte digitPins[] = {};

  // Arduino pin connections in order: A, B, C, D, E, F, G, DP
  byte segmentPins[] = {9, 8, 7, 6, 5, 4, 3, 2};
  byte displayType = COMMON_CATHODE;

  //‘false’ if resistors are connected to common pin
  bool resistorsOnSegments = true;

  //Initialize sevseg object.
  sevseg.begin(displayType, numDigits, digitPins, segmentPins,
  resistorsOnSegments);
  sevseg.setBrightness(90);
}

void loop() {
  if(!digitalRead(SW_START)){
     sevseg.setNumber(counter);
     sevseg.refreshDisplay();
     counter++;
      if(counter > 9){
        digitalWrite(BUZZER, HIGH);
        delay(500);
        digitalWrite(BUZZER, LOW);
        counter = 0;  
      }
      delay(500);
  }
}