using pullstime

I'm confused.

The % operator returns the remainder when one number is divided by another.

The reference says (my emphasis):

Syntax
remainder = dividend % divisor;
Parameters
remainder : variable. Allowed data types: int, float, double
dividend : variable or constant. Allowed data types: int
divisor : non zero variable or constant. Allowed data types: int

All OP's lines like this:

if (buttonPushCounter % 0 == 4)

.... are logically meaningless and mathematically inadmissible, since x%0 includes division by zero.

OP presumably has some successful results of the button pressing, and I find that in fact the result is always the dividend. In OP's case, that's the buttonPushCounter , which is probably what they want anyway.

Try this:

void setup()
{
  Serial.begin(9600);
  while (!Serial) {}

  int myVar1 = 11;
  int myVar2 = 0;
  int myResult1 = myVar1 % myVar2; //dividing by 0 here
  Serial.println(myVar1);
  Serial.println(myVar2);
  Serial.println(myResult1);       //returns myVar1

  myVar1 = 999;
  myResult1 = myVar1 % myVar2; //dividing by 0 here
  Serial.println(myVar1);
  Serial.println(myVar2);
  Serial.println(myResult1);       //returns myVar1

} //setup

void loop() {} //loop

I get this:

11
0
11
999
0
999

That's very odd, to me. I don't know what the C/C++ standard is supposed to do with division by 0, but it's allowing OP to get the result they expect, since I think they just want the number of button presses.

In that case:

if (buttonPushCounter % 0 == 4)

... which is meaningless but seems to provide the expected result, can just be replaced with:

if (buttonPushCounter == 4)

Can some C/C++ guru describe why x%0 returns x when division by zero is undefined? Is it by design?, or a bug in the compiler?