#include <LiquidCrystal_I2C.h>
int columns = 16;
int rows = 2;
// create an i2c object for the display then pass the setup arrgumnets, i2c address and lcd charcter sizes
LiquidCrystal_I2C LCD(0x27, columns, rows);
// "" wriiting something inside the quotes will tell the arduino this is not a code, instead this is just some charchters which we call STRINGS
String Title = " Scroll Message ";
String Messeage = "your message goes here";
// create my own custom function which will let me scroll the text accross the LCD
void scrollMesseage(int row, String text, int delayTime, int columns){ // function with 4 arrguments
// first lets push the text all the way out of the screen by adding 16 SPACES before it
for(int i = 0; i < columns; i++){ // this for loop will repeat 16 times becuase arrgument columns equal 16
text = " " + text; // every time this for loop runs, it will add one empty space before my arrgument text
}
text = text + " "; // add one empty space after the arrgument text
// next we want to start the scrolling procss from the right to the lift
for(int pos = 0; pos < text.length(); pos++ ){
LCD.setCursor(0, row);
LCD.print(text.substring(pos, pos + columns));
delay(delayTime);
}
}
void setup() {
// put your setup code here, to run once:
LCD.init(); // start the display
LCD.clear(); // clear the display
LCD.backlight(); // turn on the display light
}
void loop() {
// put your main code here, to run repeatedly:
LCD.setCursor(0, 0);
LCD.print(Title);
scrollMesseage(1, Messeage, 250, columns);
}