#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // Alamat I2C biasanya 0x27 atau 0x3F
const int ledPin = 2; // LED di pin 2
const int buttonPin = 5; // Tombol di pin 5 (INPUT_PULLUP)
String text = "#SKYENGINE Timeless Inheritance";
int scrollIndex = 0;
bool pertamaNyala = true; // Flag untuk delay awal
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
lcd.init();
lcd.backlight();
lcd.clear();
}
void loop() {
bool tombolDitekan = (digitalRead(buttonPin) == LOW);
if (tombolDitekan) {
// Baris kedua (statis)
lcd.setCursor(0, 1);
lcd.print("KZRTCC X M11XEL");
// Kalau baru pertama nyala, tampilkan text diam dulu
if (pertamaNyala) {
lcd.setCursor(0, 0);
lcd.print(text.substring(0, 16)); // tampilkan awal
delay(1000); // tahan 3 detik
pertamaNyala = false;
}
// Running text baris pertama
String displayText = text.substring(scrollIndex) + " " + text.substring(0, scrollIndex);
lcd.setCursor(0, 0);
lcd.print(displayText.substring(0, 16));
// Geser index
scrollIndex++;
if (scrollIndex >= text.length()) {
scrollIndex = 0;
}
// LED kedap kedip
digitalWrite(ledPin, HIGH);
delay(150);
digitalWrite(ledPin, LOW);
delay(150);
} else {
// Matikan LED dan LCD
digitalWrite(ledPin, LOW);
lcd.clear();
pertamaNyala = true; // Reset flag supaya saat nyala lagi tahan 3 detik
scrollIndex = 0; // Reset posisi scroll
}
}