Pushbotton Counter

A version for you to test with below, just adjust 'pinBUTTON' as required.

//#define NDEBUG

#include <Arduino.h>


#if !defined(NDEBUG)

#define DebugStr(STR)           Serial.print(STR)
#define DebugStrln(STR)         Serial.println(STR)
#define DebugDelay(MILLIS)      delay(MILLIS)

#else

#define DebugStr(STR)
#define DebugStrln(STR)
#define DebugDelay(MILLIS)

#endif


class push_button_t
{
    const uint8_t   _pin;
    const uint8_t   _transition_level;
    const uint8_t   _number_of_states;

    uint8_t         _press_counter;
    uint8_t         _state_then;

public:
    push_button_t(uint8_t pin, uint8_t transition_level = LOW, uint8_t number_of_states = 2)
        : _pin(pin)
        , _transition_level(transition_level)
        , _number_of_states(number_of_states)
        
        , _press_counter(0)
        , _state_then(0)
    {}

    void begin()
    {
        DebugStrln(__PRETTY_FUNCTION__);
    
        pinMode(_pin, INPUT);
    }

    operator uint8_t()
    {
        DebugStrln(__PRETTY_FUNCTION__);
    
        uint8_t state_now = digitalRead(_pin);
        if ( state_now != _state_then )
        {
            if ( state_now == _transition_level )
            {
                _press_counter++;
                _press_counter %= _number_of_states;
            }
        }
        
       _state_then = state_now;

       return _press_counter;
    }
};


const uint8_t   pinBUTTON = 4;


push_button_t   button(pinBUTTON, HIGH, 4);


void funct4()   { DebugStrln(__PRETTY_FUNCTION__); }
void funct3()   { DebugStrln(__PRETTY_FUNCTION__); }
void funct2()   { DebugStrln(__PRETTY_FUNCTION__); }
void funct1()   { DebugStrln(__PRETTY_FUNCTION__); }

void loop()
{
    switch ( button )
    {
        case 0: funct1(); break;
        case 1: funct2(); break;
        case 2: funct3(); break;
        case 3: funct4(); break;
    }
}

void setup()
{
#if !defined(NDEBUG)
    Serial.begin(9600);
#endif

    button.begin();
}