Thanks for the tip, I'm perhaps a newbie, but I know what clear (), is, I've tried it in slightly different locations in the code, without quite get it to work.
This is the modified code I've tried.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int switchPin = 13; // momentary switch on 8, other side connected to ground
int Display = 0;
int prevstate = HIGH;
int currstate;
void setup()
{
lcd.begin(16, 2);
pinMode(switchPin, INPUT);
digitalWrite(switchPin, HIGH); // turn on pullup resistor
}
void loop()
{
currstate = digitalRead(switchPin);
if (currstate != prevstate){
Display = Display + 1;
if(Display > 3){
lcd.clear();
Display = 1;
}
}
switch (Display) {
case 1: {
lcd.setCursor(0, 0);
lcd.print("joy");
break;
}
case 2: {
lcd.clear();
lcd.setCursor(5, 0);
lcd.print("raha");
break;
}
case 3: {
lcd.clear();
lcd.setCursor(1, 1);
lcd.print("hkfl");
break;
}
}
prevstate = currstate;
}