Hello! This is my first day playing with an Arduino and using C/C++. I learned how to make my 16x2 LCD say on the top line:
"Hello, World! This is a test."
and on the bottom line I am trying to display the number of seconds passed (millis()/1000) where the top line scrolls independently of the bottom line. However, both lines update at the same rate. I want to make the top line update (meaning scroll by one character) at a set rate that is independent of the bottom line (which should update every second).
The trouble I have had so far is whenever I use a delay() it forces the bottom LCD line, which comes later in the code, to also wait that same amount of time, so the second line is dependent on what the first line does. Is there a way to have two separate loop() statements that run at different rates?
I also tried coming up with a way that would make the top line change after a set number of milliseconds have passed by, but I don't know how to calculate the delta of a variable. My programming background is in Garry's Mod with Expression 2, which allows me to set the rate that the chip iterates at and has built-in functions like delta() which gives the change in a variable (or input) since the last iteration.
Any help or advice would be awesome!
Here is the code I am using:
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
String Message;
String Display;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Message = "Hello, World! This is a test";
lcd.print(Message);
delay(1000);
}
void loop() {
lcd.setCursor(0, 0);
if (Display.length() <= 16) {
Display = Message;
lcd.print(Display);
} else {
Display.setCharAt(0,' ');
Display.trim();
lcd.print(Display);
}
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
delay(1000);
}