Coding for a Biathlon Timer -stop watch with intervals controled by a microphone

Hi,
I am creating a timer to mark the shooting intervals a biathlete takes. This is the total time they take from putting down their ski poles, shoot and pick them up again. The time between each shot is recorded as an interval.
Here is a YouTube video of what I am talking about.

I have created a simple stop watch using an UNO, but I have several challenges that I need help with.

1 - The total stops displaying (freezes after the second interval)
2 - the total time starts when the button is pressed, while the first timer starts when the button is released (both should be the same (released))
3 -The total time doesn’t reset at the end and just continues.

I intend on adding the microphone once I have the above fixed. Any suggestions on how to do this would be great. It will be acting as a third button and start the next interval everytime it registors a gun shot. I will need to set the tolerance level high so other noises dont set it off.

Thanks for all suggestions

my sketch broke the 9000 character limit. I will post it below in the comments

Here is my sketch (it broke the 9000 character limit in the original post)

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
 
//define the six timer states.
#define WAITING 0 // waiting to start
#define TIMERONE 1 // timer 1 running
#define TIMERTWO 2 // timer 2 running
#define TIMERTHREE 3 // timer 3 running
#define TIMERFOUR 4 // timer 4 running
#define TIMERFIVE 5 // timer 5 running
#define FINISHED 6 // timer complete
 
const long minute = 60000; 
const int resetPin = 2;
const int buttonPin = 3;
const int ledPin =  13;      
unsigned long previousTime=0 ;
long startTime = 0;
long timeOne = 0;
long timeTwo = 0;
long timeThree = 0;
long timeFour = 0;
long timeFive = 0;
int timer = WAITING; // timer state. waiting for first button press

int reset = 0;  // reset button state
int button = 0; // interval button state
 
void setup()   {    
  pinMode(buttonPin, INPUT); // interval button pin to input
  pinMode(resetPin, INPUT);  // reset pin to input
  pinMode(ledPin, OUTPUT); // initialize the LED pin as an output:
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3c
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  printDigits(0);
   
}
 
void loop() {
   //*********main loop ************
 switch ( timer){
   case WAITING: // initial state - 
     display.clearDisplay();
     display.setCursor(10,00);
     printDigits(0);
     display.display();                        // display screen showing 00:00s
     button = digitalRead(buttonPin);
      reset = digitalRead(resetPin);
     if(button){                     // button is pressed.
       timer = TIMERONE; // start the first timer
     while (digitalRead(buttonPin)){
         startTime = millis();//read the time the button is pressed.
         //--- wait for button to be released.
          }
     }
 //***********************
   break;
   case TIMERONE: //running first timer
     timeOne = millis();
     button = digitalRead(buttonPin);
     reset = digitalRead(resetPin);
     display.clearDisplay();
     display.setCursor(10,0);
     printDigits(timeOne); // display the total Time on top line
     display.setCursor(10,8);
     printDigits(timeOne - startTime); //Display interval 1 time
     display.display();
     //------------
     if(reset){        //reset button was pressed. Clear screen and start again
       timer = WAITING;
       while (digitalRead(resetPin)){
         //--- wait for reset button to be released.
       }
     }
     //------------
     if(button){                     // button was pressed
         timer = TIMERTWO;              // start the second timer
         timeTwo = millis();                                 //record the time for the start of the second timer
         while (digitalRead(buttonPin)){
           //--- wait for button to be released.
         }
       }

//********************
   break;
   case TIMERTWO: //running 2nd t timer
     timeTwo = millis();
     button = digitalRead(buttonPin);
     reset = digitalRead(resetPin);
     display.clearDisplay();
      display.setCursor(10,0);
     printDigits(timeOne); // display the total Time on top line
     display.setCursor(10,8);
     printDigits(timeOne - startTime); // display the first time time
     display.setCursor(60,8);
     printDigits(timeTwo - timeOne); // display the second timer on the line below
     display.display();
     //-------------
     if(reset){     //reset button
       timer = WAITING;
       while (digitalRead(resetPin)){
         //--- wait for reset button to be released.
       }
     }
     //------------------
     if(button){ // button was pressed
         timer = TIMERTHREE;  // start the second timer
         while (digitalRead(buttonPin)){
           //--- wait for button to be released.
         }
       }

//*********************
         break;
   case TIMERTHREE: //running 3rd timer
     timeThree = millis();
     button = digitalRead(buttonPin);
     reset = digitalRead(resetPin);
     display.clearDisplay();
         display.setCursor(10,0);
     printDigits(timeOne); // display the total Time on top line
     display.setCursor(10,8);
     printDigits(timeOne - startTime); // display the first time
     display.setCursor(60,8);
     printDigits(timeTwo - timeOne); // display the second timer on the line below
     display.setCursor(10,16);
     printDigits(timeThree - timeTwo); // display the 3rd timer on the line below
     display.display();
     //---------------
     if(reset){ //reset button was pressed. Clear screen and start again.
       timer = WAITING;
       while (digitalRead(resetPin)){
         //--- wait for reset button to be released.
       }
     }
     //---------------
     if(button){ // button was pressed
         timer = TIMERFOUR;  // start the 4th timer
         while (digitalRead(buttonPin)){
           //--- wait for button to be released.
         }
       }

//*****************
    break;
   case TIMERFOUR: //running 4th timer
     timeFour = millis();
     button = digitalRead(buttonPin);
     reset = digitalRead(resetPin);
     display.clearDisplay();
     display.setCursor(10,0);
     printDigits(timeOne); // display the total Time on top line
     display.setCursor(10,8);
     printDigits(timeOne - startTime); // display the first time time
     display.setCursor(60,8);
     printDigits(timeTwo - timeOne); // display the second timer on the line below
     display.setCursor(10,16);
     printDigits(timeThree - timeTwo); // display the 3rd timer on the line below
     display.setCursor(60,16);
     printDigits(timeFour - timeThree); // display the 4th timer on the line below
     display.display();
     //---------------
     if(reset){ //reset button 
       timer = WAITING;
       while (digitalRead(resetPin)){
         //--- wait for reset button to be released.
       }
     }
     //----------------
     if(button){ // button was pressed
         timer = TIMERFIVE;  // start the 5th timer
         while (digitalRead(buttonPin)){
           //--- wait for button to be released.
         }
       }
//***************
  break;
   case TIMERFIVE: //running 5th timer
     timeFive = millis();
     button = digitalRead(buttonPin);
     reset = digitalRead(resetPin);
     display.clearDisplay();
     display.setCursor(10,0);
     printDigits(timeOne); // display the total Time on top line
     display.setCursor(10,8);
     printDigits(timeOne - startTime); // display the first time time
     display.setCursor(60,8);
     printDigits(timeTwo - timeOne); // display the second timer on the line below
     display.setCursor(10,16);
     printDigits(timeThree - timeTwo); // display the 3rd timer on the line below
     display.setCursor(60,16);
     printDigits(timeFour - timeThree); // display the 4th timer on the line below
     display.setCursor(30,24);
     printDigits(timeFive - timeFour); // display the 5th timer on the line below
     display.display();
     //--------------
     if(reset){ //reset button 
       while (digitalRead(resetPin)){
         //--- wait for reset button to be released.
       }
     }
     //--------------
     if(button){ // button was pressed
         timer = FINISHED;  // start the second timer
         while (digitalRead(buttonPin)){
           //--- wait for button to be released.
         }
       }
        //*****************
   break;
    case FINISHED: //finished timer
     reset = digitalRead(resetPin);
     if(reset){                        //reset buttonn
       display.clearDisplay();
       display.setCursor(10,0);
       printDigits(0);
       display.display();
       timer = WAITING;
   startTime=previousTime;
   timeOne=previousTime;
       while (digitalRead(resetPin)){
         //--- wait for reset button to be released.
       }
     }  
   }
  }
void printDigits(long timeInMillis){
  // convert the time from milliseconds to four digit SS:HH
  // seconds and hundredths and display at current cursor position
  int seconds;
  int hundredths;
  seconds = timeInMillis /1000;
  seconds = seconds % 60; // seconds never more than 60
  hundredths = (timeInMillis % 1000)/10; 
  if (seconds <10){ // print leading zero if necessary
    display.print("0");
  }
  display.print(seconds);
  display.print(":");
  if (hundredths <10){ //print leading zero if necessary
  display.print("0"); 
  }
  display.print(hundredths);
  display.print("s");
  //display.display();
}

It looks to me like the program is always writing to the display. If so, that is a mistake.

The Arduino can write to the display thousands of times faster than it can respond, so you should write to the display only when the value to be displayed actually changes.

Start with something much simpler, one timer, with start/stop/reset. Once you understand the basics, it will be much easier to expand the program.

I hope you are aware that the crystal on the Arduino Uno is quite inaccurate, and that your stopwatch won't agree with a commercial one.