Change LCD Text on Button Press (Using IF ELSE)

Hey everyone,

I'm working on and what I'm trying to do is to switch the text on the LCD display everytime the button is pressed. I think I'm pretty close but I'm sure I'm messing up when it comes to the state of the button. I'm outside right now so I wont be able to make edits for a few hours but here's my code:

// include the library code:
#include<LiquidCrystal.h>
int buttonState = 0; //initialize push button state
int pb = 6; //initialize push button state

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int counter = 0;

void setup() {
  pinMode(pb, INPUT); //set pb as input

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

  //  lcd.setCursor(0, 1);
  //  lcd.clear();
  lcd.print("Dad Joke 4000");
}

void loop() {

  while (counter == 0) {
    buttonState = digitalRead(pb);
    if (buttonState == HIGH) {
      lcd.clear();
      lcd.print("test");
      lcd.setCursor(0,1);
      lcd.print("jason");
      lcd.setCursor(0,0); 
      delay(3000);
      counter = 1;
    } else if (counter == 1 && buttonState == HIGH) {
      lcd.clear();
      lcd.print("Test Failed");
    }

  }

}

The problem is that the text stays on the screen after the button press. I want to change the text on each press / move into the next else if statement

Delta_G:
You forgot to tell us what the problem is. What happens? How does that compare with what you expected?

My bad!

What happens is after the first button press the next else if statement doesn't run. The text remains on the screen even when I press the button again.

Delta_G:
That else if statement needs counter to equal 1. Now look at the while loop it is inside. If counter equals 1 the code can never get to that else if statement.

Oh okay that makes sense. So what if I take it out of the loop and just run it as an if/else statement? do you think that would help at all?

jasona:
Oh okay that makes sense. So what if I take it out of the loop and just run it as an if/else statement? do you think that would help at all?

Definitely not. It's just that you never change the value of counter again, once you set it to 1. Why?