Small project, but can't wrap my head around the code

The idea is simple. I want a push button to toggle an LCD between 4 to 6 different sets of text for an office status indicator (free, busy, lunch, break, etc.)

I've been looking at snippets of code and tutorials for the individual elements for 2 hours now, and can't get any combination to work.

I'm building this in Autodesk Circuits ( before I build the actual one.

Project here:

I've fiddled with the code so much, it's probably worthless. I'm going to have to scrap the code and go at it again, but I am just so frustrated that I can't figure out something so simple and I don't know where to start.

To do it simply, put your messages into an array of strings (note small s). Look at the state change detection example in the IDE digital examples. That example has a button count function. The button count can be the index to the array to fetch the string to display. Cycle through the messages until the one you want is up.

Like this, but replace the Serial println with lcd.print.

const char* messages[] = {
  "IN", "OUT", "BUSY", "LUNCH", "BRB"};

const byte  buttonPin = 2;

// Variables will change:
int buttonPushCounter = 0;
int buttonState = HIGH;
int lastButtonState = HIGH;

void setup()
  pinMode(buttonPin, INPUT_PULLUP);  // will be LOW when pushed

void loop()
  buttonState = digitalRead(buttonPin); // get new state
  if (buttonState != lastButtonState)  // has the state changed?
    if (buttonState == LOW)  // yes, changed and changed to pushed
      if(buttonPushCounter > 4)  // reset to zero if past end of messages array 
        buttonPushCounter = 0;
      Serial.println(messages[buttonPushCounter]);  // replace with lcd print
    lastButtonState = buttonState;  // save this state 


Awesome. That helps me understand it. I was able to get it to run in the simulator by switching to the lcd.print and adding the #include part to run the regular LCD outputs instead of the serial. It isn't working in the simulator (when you push the button, nothing happens) and I'm not sure if that's a limitation of the simulator or if something else is missing, but I think you have me on the right track now! Thank you so much!

I really need to build more projects from tutorial to learn the code better, but this is something I wanted to tinker with.