Detecting Third button press

When you use delay( ) in your sketches (which we seldom do) your sketch is slow to respond.

We recommend you use millis( ) TIMING and not use delay( )s.

What does that mean?

also how would you use millis()? in my code?

As mentioned by member @TheMemberFormerlyKnownAsAWOL, how can your LEDs emit light if you do not make those pins outputs ?


EDIT
Can we give these pins some names that mean something ?

  pinMode(11, INPUT_PULLUP); 
  pinMode(12, INPUT_PULLUP); 
  pinMode(13, INPUT_PULLUP); 

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Look at this code (it is not finished yet).
Do you understand what is being done ?

#define CLOSED             LOW
#define OPEN               HIGH

#define LEDoff             LOW
#define LEDon              HIGH

#define ENABLED            true
#define DISABLED           false


bool LEDcountingFlag     = DISABLED;

const byte counterButton = 11;
const byte startButton   = 12;
const byte resetButton   = 13;

const byte ledOne        = 4;
const byte ledTwo        = 5;
const byte ledThree      = 6;
const byte ledFour       = 7;

const byte heartbeatLED  = 9;

byte counter;
byte LEDcount;


byte buttonState;
byte buttonState2;
byte buttonState3;

byte lastButtonState     = OPEN;
byte lastButtonState2    = OPEN;
byte lastButtonState3    = OPEN;

//timing stuff
unsigned long currentMillis;
unsigned long heartbeatMillis;
unsigned long switchMillis;
unsigned long LEDmillis;


void setup()
{
  Serial.begin(9600);
  pinMode(ledOne, OUTPUT);
  pinMode(ledTwo, OUTPUT);
  pinMode(ledThree, OUTPUT);
  pinMode(ledFour, OUTPUT);

  pinMode(heartbeatLED, OUTPUT);

  pinMode(counterButton, INPUT_PULLUP);
  pinMode(startButton, INPUT_PULLUP);
  pinMode(resetButton, INPUT_PULLUP);

} //END of setup()

void loop()
{
  //get the currentArduino run time
  currentMillis = millis();

  //*************************************                   heartbeat TIMER
  //used to see if our code is blocking
  //the heartbeat LED should regularly toggle, every 1/2 second
  //is it time to toggle the LED ?
  if (currentMillis - heartbeatMillis >= 500)
  {
    //restart the TIMER
    heartbeatMillis = currentMillis;

    //toggle the LED  uncomment to enable th heartbeat LED flashing
    digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
  }

  //*************************************                   read switch TIMER
  //is it time to check the switches ?
  if (currentMillis - switchMillis >= 50)
  {
    //restart the TIMER
    switchMillis = currentMillis;

    checkSwitches();
  }

  //*************************************                   LED counter TIMER
  //if enabled is it time to go to the next LED sequence
  if (LEDcountingFlag == ENABLED && currentMillis - LEDmillis >= 1000ul)
  {

  }


} //END of loop()


//*******************************************************************************************
//scan the switches to see if there was a change in state
void checkSwitches()
{
  //*************************************
  buttonState = digitalRead(counterButton);

  //was there a switch change in state ?
  if (lastButtonState != buttonState)
  {
    //update to the new state
    lastButtonState = buttonState;

    //did the switch close ?
    if (buttonState == CLOSED)
    {
      if (counter < 15)
      {
        counter++;
      }

      else
      {
        counter = 0;
      }

      Serial.println(counter);
    }
  }

  //*************************************
  buttonState2 = digitalRead(startButton);

  //was there a switch change in state ?
  if (lastButtonState2 != buttonState2)
  {
    //update to the new state
    lastButtonState2 = buttonState2;

    //did the switch close ?
    if (buttonState2 == CLOSED)
    {
      //enable LED counter display
      LEDcountingFlag = ENABLED;
    }
  }

  //*************************************
  buttonState3 = digitalRead(resetButton);

  //was there a switch change in state ?
  if (lastButtonState3 != buttonState3)
  {
    //update to the new state
    lastButtonState3 = buttonState3;

    //did the switch close ?
    if (buttonState3 == CLOSED)
    {
      //disable the LED sequence and turn off the LEDs
      LEDcountingFlag = DISABLED;
      digitalWrite(ledOne, LEDoff);
      digitalWrite(ledTwo, LEDoff);
      digitalWrite(ledThree, LEDoff);
      digitalWrite(ledFour, LEDoff);

      //reset sequence
      counter = 0;

    }
  }

} //END of checkSwitches()



Should be close:

//https://forum.arduino.cc/t/detecting-third-button-press/919620/1

// Version  YY/MM/DD    Description
// 1.00     21 10 29    functioning sketch

#define CLOSED             LOW
#define OPEN               HIGH

#define LEDoff             LOW
#define LEDon              HIGH

#define ENABLED            true
#define DISABLED           false

//*******************************************************************************************

bool LEDcountingFlag     = DISABLED;

const byte led1          = 4;
const byte led2          = 5;
const byte led4          = 6;
const byte led8          = 7;

const byte heartbeatLED  = 10;

const byte counterButton = 11;
const byte startButton   = 12;
const byte resetButton   = 13;

byte counter;
byte LEDcount;


byte buttonState;
byte buttonState2;
byte buttonState3;

byte lastButtonState     = OPEN;
byte lastButtonState2    = OPEN;
byte lastButtonState3    = OPEN;

//timing stuff
unsigned long currentMillis;
unsigned long heartbeatMillis;
unsigned long switchMillis;
unsigned long LEDmillis;


//*******************************************************************************************
void setup()
{
  Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led4, OUTPUT);
  pinMode(led8, OUTPUT);

  pinMode(heartbeatLED, OUTPUT);

  pinMode(counterButton, INPUT_PULLUP);
  pinMode(startButton, INPUT_PULLUP);
  pinMode(resetButton, INPUT_PULLUP);

} //END of setup()


//*******************************************************************************************
void loop()
{
  //get the currentArduino run time
  currentMillis = millis();

  //*************************************                   heartbeat TIMER
  //used to see if our code is blocking
  //the heartbeat LED should regularly toggle, every 1/2 second
  //is it time to toggle the LED ?
  if (currentMillis - heartbeatMillis >= 500)
  {
    //restart this TIMER
    heartbeatMillis = currentMillis;

    //toggle the LED  
    //comment the next line to stop heartbeat LED flashing
    digitalWrite(heartbeatLED, !digitalRead(heartbeatLED));
  }

  //*************************************                   read switch TIMER
  //is it time to check the switches ?
  if (currentMillis - switchMillis >= 50)
  {
    //restart this TIMER
    switchMillis = currentMillis;

    checkSwitches();
  }

  //*************************************                   LED display TIMER
  //if enabled is it time to go to the next LED sequence
  if (LEDcountingFlag == ENABLED && currentMillis - LEDmillis >= 1000ul)
  {
    //restart this timer
    LEDmillis = currentMillis;

    //adjust the LEDs to the current count
    digitalWrite(led1, LEDcount & 0b0001);
    digitalWrite(led2, LEDcount & 0b0010);
    digitalWrite(led4, LEDcount & 0b0100);
    digitalWrite(led8, LEDcount & 0b1000);

    //get ready for the next LED display
    if (LEDcount++ >= counter)
    {
      //back to the beginning
      LEDcount = 0;
    }
  }

} //END of loop()


//*******************************************************************************************
//scan the switches to see if there was a change in state
void checkSwitches()
{
  //*************************************
  buttonState = digitalRead(counterButton);

  //was there a switch change in state ?
  if (lastButtonState != buttonState)
  {
    //update to the new state
    lastButtonState = buttonState;

    //did the switch close ?
    if (buttonState == CLOSED)
    {
      //are we at the maximum count yet ?
      if (counter < 15)
      {
        counter++;
      }

      //back to zero
      else
      {
        counter = 0;
      }

      Serial.println(counter);
    }
  }

  //*************************************
  buttonState2 = digitalRead(startButton);

  //was there a switch change in state ?
  if (lastButtonState2 != buttonState2)
  {
    //update to the new state
    lastButtonState2 = buttonState2;

    //did the switch close ?
    if (buttonState2 == CLOSED)
    {
      //enable LED counter display
      LEDcountingFlag = ENABLED;
    }
  }

  //*************************************
  buttonState3 = digitalRead(resetButton);

  //was there a switch change in state ?
  if (lastButtonState3 != buttonState3)
  {
    //update to the new state
    lastButtonState3 = buttonState3;

    //did the switch close ?
    if (buttonState3 == CLOSED)
    {
      //disable the LED sequence and turn off the LEDs
      LEDcountingFlag = DISABLED;
      
      digitalWrite(led1, LEDoff);
      digitalWrite(led2, LEDoff);
      digitalWrite(led4, LEDoff);
      digitalWrite(led8, LEDoff);

      //reset the count to values
      counter = 0;
      LEDcount = 0;
    }
  }

} //END of checkSwitches()


//*******************************************************************************************

Hello,
check out the proposal for your school assignement.

/* BLOCK COMMENT
  ATTENTION: This Sketch contains elements of C++.
  https://www.learncpp.com/cpp-tutorial/
  https://forum.arduino.cc/t/detecting-third-button-press/919620
*/
#define ProjectName "Detecting Third button press"
// hardware and timer settings
constexpr byte ButtonOnePin {A0};      // portPin o---|button|---GND
constexpr byte ButtonTwoPin {A1};      // portPin o---|button|---GND
constexpr byte ButtonThreePin {A2};     // portPin o---|button|---GND
constexpr byte Led2Pow0Pin {2};        // portPin o---|220|---|LED|---GND
constexpr byte Led2Pow1Pin {3};        // portPin o---|220|---|LED|---GND
constexpr byte Led2Pow2Pin {4};        // portPin o---|220|---|LED|---GND
constexpr byte Led2Pow3Pin {5};        // portPin o---|220|---|LED|---GND
unsigned long BlinkDuration {1000}; // times in msec
// CONSTANT DEFINITION
// forward declaration using function prototype
void blinkBlink();
void buttonOnePressed();
void buttonOneReleased();
void buttonTwoPressed();
void buttonTwoReleased();
void buttonThreePressed();
void buttonThreeReleased();
// VARIABLE DECLARATION AND DEFINITION
unsigned long currentTime;
struct TIMER {              // has the following members
  unsigned long duration;   // memory for interval time
  bool repeat_;             // control for blinking
  bool control_;            // control for start/stop
  unsigned long stamp;      // memory for actual time
};
struct BUTTON {
  byte pin;
  bool statusQuo;
  void (*task[2])();
  unsigned long stamp;
  unsigned long duration;
} buttons[] {
  {ButtonOnePin, false, {buttonOneReleased, buttonOnePressed}, 0, 20},
  {ButtonTwoPin, false, {buttonTwoReleased, buttonTwoPressed}, 0, 20},
  {ButtonThreePin, false, {buttonThreeReleased, buttonThreePressed}, 0, 20},
};
struct BOX {
  byte leds[4];
  int counter;
  TIMER timer;
} box {{Led2Pow0Pin, Led2Pow1Pin, Led2Pow2Pin, Led2Pow3Pin}, 0, BlinkDuration, true, false, 0};
// ------------------ USER FUNCTIONS ---------------
bool checkTimer(TIMER & time_) {  // generic time handler using TIME struct
  if (currentTime - time_.stamp >= time_.duration && time_.control_) {
    if (time_.repeat_) time_.stamp = currentTime;
    else time_.control_ = false;
    return true;
  } else return false;
}
void startTimer(TIMER &timer) {
  timer.control_ = true;
  timer.stamp = currentTime;
}
void stoppTimer(TIMER &timer) {
  timer.control_ = false;
}
void checkButton() {
  for (auto &button_ : buttons) {
    if (currentTime - button_.stamp >= button_.duration) {
      button_.stamp = currentTime;
      bool stateNew = !digitalRead(button_.pin);
      if (button_.statusQuo != stateNew) {
        button_.statusQuo = stateNew;
        button_.task[stateNew]();
      }
    }
  }
}
void blinkBlink() {
  box.counter++;
}
void upDate() {
  int element = 1;
  for (auto led : box.leds) digitalWrite (led, (box.counter & element ? 1 : 0)), element *= 2;
}
void buttonOnePressed() {
  box.counter++;
}
void buttonOneReleased() {
 }
void buttonTwoPressed() {
   startTimer(box.timer);
}
void buttonTwoReleased() {
}
void buttonThreePressed() {
   stoppTimer(box.timer);
   box.counter=0;
}
void buttonThreeReleased() {
}
void setup() {
  Serial.begin(9600);
  Serial.println(F("."));
  Serial.print(F("File   : ")), Serial.println(__FILE__);
  Serial.print(F("Date   : ")), Serial.println(__DATE__);
  Serial.print(F("Project: ")), Serial.println(ProjectName);
  pinMode (LED_BUILTIN, OUTPUT);  // used as heartbeat indicator
  //  https://www.learncpp.com/cpp-tutorial/for-each-loops/
  for (auto Button : buttons) pinMode(Button.pin, INPUT_PULLUP);
  for (auto Output : box.leds) pinMode(Output, OUTPUT);
  // check outputs
  for (auto Output : box.leds) digitalWrite(Output, HIGH), delay(100);
  for (auto Output : box.leds) digitalWrite(Output, LOW), delay(100);
}
void loop () {
  currentTime = millis();
  digitalWrite(LED_BUILTIN, (currentTime / 500) % 2);
  if (checkTimer(box.timer)) blinkBlink();
  checkButton();
  upDate();
}

Have a nice day and enjoy coding in C++.