Button Pressing with Counter

Trying to get my LCD to print something different each time the button is pressed. However once it is clicked it remains in the first while loop and despite clicking it again, it doesn’t register. I assume this is because I haven’t got the button pressing function within the loop however even when I copy that first half of code into the loop it still doesn’t work. How can I get it to register a click has been made within the loop

buttonState = digitalRead(buttonPin);

  if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {
      buttonPushCounter++;
    }
    delay(50);
  }

-------------------------------------------------------------------------------

  while ((voltage < 6) && (buttonPushCounter == 1)) 
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(String("Menu 1"));
    delay(5000); 
  }
  while (buttonPushCounter == 2) 
  {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print(String("Menu 2"));
    delay(5000); 
  }

You forgot to update lastButtonState.

where would I write it? within the loop?

angusryan_:
where would I write it? within the loop?

A convenient place is just before you read the button state again.