Arduino Uno Push Button State Change

Hello, everytime the button is pressed, I want it to react or run a function. For example, if the button is pressed once, it will print out hello, if it's pressed twice, print bye, etc, but when I run the program, it prints out hello infinite amount of times, until i press the button again. I want it to only print out once or only the run the first button state once. Here is my code:

int button = 6; int buttonState = 0; int buttonPushCounter = 0; int lastButtoneState = 0;

void setup() { pinMode(button, INPUT): Serial.begin(9600); }

void loop() { buttonState = digitalRead(button);

if(buttonState == HIGH) { buttonPushCounter++; Serial.print("Number of button pushes"); Serial.println(buttonPushCounter, DEC); } else { Serial.println("OFF"); } delay(50); }

lastButtonState = buttonState;

if(buttonPushCounter == 1) { Serial.println("HELLO"); } if(butotnPushCounter == 2) { Serial.println("BYE"); }

}

Your thread title says state change, but it is clear that you have not looked at the state change detection example.

...and that you have not read the forum guidelines for posting code.