#include <LiquidCrystal_I2C.h>
const int DELAY_RUNNING = 150;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void runKananKeKiri(String text, int y, int index = -1) {
if (index == text.length() - 1) return;
if (index == -1) {
index = 0;
}
char stringDisplay[17];
stringDisplay[16] = 0;
for (int i = 0; i < 16; i++) {
if (index + i < text.length()) {
stringDisplay[i] = text[index + i];
} else {
stringDisplay[i] = 32; // spasi
}
}
lcd.clear();
lcd.setCursor(0,y);
lcd.print(stringDisplay);
delay(DELAY_RUNNING);
runKananKeKiri(text, y, index+1);
}
void gerakKiriKeKanan(int pergeseran = 16) {
for (int i = 0; i < pergeseran; i++) {
lcd.scrollDisplayRight();
delay(DELAY_RUNNING);
}
}
void setup() {
lcd.init();
lcd.backlight();
// put your setup code here, to run once:
}
void loop() {
lcd.home();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Selamat Datang");
gerakKiriKeKanan();
runKananKeKiri("Universitas Amikom Yogyakarta",1);
}