/*
Rob's first project
20 Feb 2024
Brisbane
*/
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
int totalColumns = 16;
int totalRows = 2;
String staticMessage = "Hello World";
String scrollingMessage = "Welcome to Rob's Arduino";
void scrollMessage(int row, String message, int delayTime, int totalColumns) {
for (int i=0; i < totalColumns; i++) {
message = " " + message;
}
message = message + " ";
for (int position = 0; position < message.length(); position++) {
lcd.setCursor(0, row);
lcd.print(message.substring(position, position + totalColumns));
delay(delayTime);
}
}
void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(2,0);
lcd.print(staticMessage); // Print a message to the LCD.
lcd.setCursor(2,1);
lcd.print("*");
delay(2000);
}
void loop()
{
scrollMessage(1, scrollingMessage, 300, totalColumns);
}