If the code is in setup() you will have to hold the button pressed and reset the Arduino to ever print "Jon" and what will be printed is "Hello AllJon". The lcd constuctor
void setup()
{
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
is still in setup(). It should be outside of setup().
Here is code to print "Hello All" at start up and cycle through "Jon", "Jimmy" and "Sid" at each button press. Since there is no switch debounce it may act a bit funny, but should show a way to do what you want. The links that I provided and the comments in the code will explain much of the concepts in the code.
#include <LiquidCrystal.h>
const byte buttonPin = 7;
int buttonPushCounter = 0; // counter for the number of button presses
boolean buttonState = LOW; // current state of the button
boolean lastButtonState = LOW; // previous state of the button
// lcd constructor made global in scope so the whole program can sse it
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Hello All");
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop()
{
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
// compare the buttonState to its previous state
if (buttonState != lastButtonState)
{
if (buttonState == HIGH)
{
// if the current state is HIGH then the button
// went from off to on:
buttonPushCounter++; // add one to counter
lcd.clear();
if (buttonPushCounter > 3) // if couter over 3 reset the counter to 1 to show "Jon"
// and not "Hello All"
{
buttonPushCounter = 1;
}
Serial.println(buttonPushCounter);
switch (buttonPushCounter) // choose what to display based on buttonPushCounter value
{
case 0:
lcd.print("Hello All"); // show "Hello All until first button press
break;
case 1:
lcd.print("Jon");
break;
case 2:
lcd.print("Jimmy");
break;
case 3:
lcd.print("Sid");
break;
}
}
// save the current state as the last state,
//for next time through the loop
lastButtonState = buttonState;
}
}