How to Make Arduino LCD Show Lyrics in wokwi
Yo fam! Today we’re gonna cook up something cool with Arduino: making an LCD display your fav lyrics with a typewriter effect π€―. Perfect if you wanna flex your Arduino skills on your friends or just make your own DIY karaoke machine π.
What You Need
-
1x Arduino UNO
-
1x LCD 20x4 with I2C backpack
-
Jumper wires (aka drip cables)
-
(Optional) Breadboard if you like things nead
Circuit Setup
Wire it like this (super simple cuz I2C saves lives):
-
LCD GND → Arduino GND
-
LCD VCC → Arduino 5V
-
LCD SDA → Arduino A4
-
LCD SCL → Arduino A5
Boom. Done. No messy spaghetti wiring here.
Before coding, make sure you got these libraries in your Arduino IDE or Wokwi:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
The Code
Here’s the full code you can use (yes, already polished for LCD 20x4):
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4); // I2C address, LCD 20x4
// Lyrics list
String lirik[] = {
"Tante...",
"Sudah terbiasa terjadi tante...",
"Teman datang cuma kalo butuh saja...",
"Coba kalau lagi susah...",
"Mereka semua menghilaaaaaang..."
};
int jumlahLirik = sizeof(lirik) / sizeof(lirik[0]);
void setup() {
lcd.init();
lcd.backlight();
}
void loop() {
for (int i = 0; i < jumlahLirik; i++) {
// Split into 4 lines (max 20 chars each)
String baris1 = lirik[i].substring(0, 20);
String baris2 = "";
String baris3 = "";
String baris4 = "";
if (lirik[i].length() > 20) baris2 = lirik[i].substring(20, 40);
if (lirik[i].length() > 40) baris3 = lirik[i].substring(40, 60);
if (lirik[i].length() > 60) baris4 = lirik[i].substring(60, 80);
lcd.clear();
lcd.setCursor(0, 0); ketikCepat(baris1);
lcd.setCursor(0, 1); ketikCepat(baris2);
lcd.setCursor(0, 2); ketikCepat(baris3);
lcd.setCursor(0, 3); ketikCepat(baris4);
delay(2000); // pause before next lyric
}
}
// Typewriter effect
void ketikCepat(String teks) {
for (int i = 0; i < teks.length(); i++) {
lcd.print(teks[i]);
delay(40); // typing speed
}
}
How It Works
-
LCD gets initialized and lit up.
-
Lyrics are stored in an array (so you can add more easily).
-
Each lyric is split into max 4 lines (20 chars per line).
-
The text pops up letter by letter with a typewriter effect ✍️.
-
After 2 seconds, it switches to the next lyric.
Pro Tips
-
Wanna type faster? Lower the delay in
ketikCepat()
. -
Wanna hold lyrics longer? Increase
delay(2000);
. -
LCD is only 20x4 → so anything past 80 chars will get cut.
krisna andika nugraha fix
Komentar
Posting Komentar