#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int totalColumns = 20;
int totalRows = 4;
LiquidCrystal_I2C lcd(0x27,20,4);
String line1 = "HI! I'M INNO:)"; // static
String line2 = "Mabuhay MinSUans!"; // static
String line3 = ("Welcome to BTVTED & BTLED DEPARTMENT BTLED offer Home Economics and Industrial Arts"); //scroll message");
String line4 = (" BTVTED offer Electronics Technology, Drafting Technology, Electrical Technology, Automotive Technology, Food Service and Management, Fashion and Garments Technology"); //scroll message
int stringStart = 0;
int stringEnd = 0;
int scrollCursor = totalColumns;
void setup(){
lcd.init();
lcd.backlight();
lcd.begin(totalColumns, totalRows);
}
void loop(){
lcd.setCursor(3, 0); // Seting the cursor on first row
lcd.print(line1); // To print line1 message
lcd.setCursor(2, 1); // Seting the cursor on Second row
lcd.print(line2); // To print line2 message
delay(1500);
lcd.clear();
lcd.setCursor(scrollCursor, 2);// Seting the cursor on first row and (scrolling from left end to right)
lcd.print(line3.substring(stringStart, stringEnd)); // To print line1 first character "w"
lcd.setCursor(scrollCursor,3);
lcd.print(line4.substring(stringStart, stringEnd));
if (stringStart == 0 && scrollCursor > 0){
scrollCursor --; // Moving cursor from 16 to 0
stringEnd ++; // Character W, E, L, C, O, M, E, ...
}
else if (stringStart == stringEnd){ // start all over again
stringStart = stringEnd = 0;
scrollCursor = totalColumns;
}
else if (stringEnd == line1.length() && scrollCursor == 0) { // if reach to the end character
stringStart++;
}
else if (stringEnd == line2.length() && scrollCursor == 1) { // if reach to the end character
stringStart++;
}
else if (stringEnd == line3.length() && scrollCursor == 2) { // if reach to the end character
stringStart++;
}
else { // it will print out character from (1 to 16) to end character (this case it's !))
stringStart++;
stringEnd++;
}
}