Hello, good day. This program will display text on the 16x2 lcd on line 1 and 2, and the text on line 2 will scroll. But I want when the button is pressed, on line 2 the text will change the other text but not scrolling. I tried my program and on line 2 "text" can scroll then I press the button but there is no change. Can you please give me a solution. thank you for your help.
This my program code :
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
int Pressed1 = 0;
int buttonPin1 = 2;
String txtsc,txtnosc;
void setup(){
txtsc="Press the button ";
lcd.begin();
lcd.setCursor(0,0);
lcd.print("Welcome ");
}
void loop(){
lcd.setCursor(0,1);
txtsc=ScrollTxt(txtsc);
lcd.print(txtsc);
delay(300);
if(Pressed1 == 0) {
if (digitalRead(buttonPin1) == HIGH) {
Pressed1 = 1;
} else {
lcd.setCursor(0,1);
lcd.print("Thank You! ");
}
}
}
String ScrollTxt(String txt){
return txt.substring(1,txt.length()) + txt.substring(0,1);
}
The result that I want looks :
Welcome
Press the button <<<this line will scroll
<When button pressed>
Welcome
Thank you <<<not scroll