#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 4); // Assuming 0x27 is the correct I2C address for your LCD
int animationPhase = 0;
int animationFrame = 0;
void setup() {
lcd.init(); // initialize the lcd
lcd.backlight(); // Turn on the backlight
}
void loop() {
// Clear the screen
lcd.clear();
// Update animation
animationFrame++;
if (animationFrame == 16) {
animationFrame = 0;
animationPhase++;
if (animationPhase > 3) {
animationPhase = 0;
}
}
// Display the rolling animation
if (animationPhase == 0) {
displayNewMugASCII();
} else if (animationPhase == 1) {
displayRollingCigarette(animationFrame);
}
delay(200); // Adjust the delay to control the speed of the animation
}
void displayNewMugASCII() {
// Display the new ASCII art for the mug
lcd.setCursor(2, 0);
lcd.print(" ((");
lcd.setCursor(2, 1);
lcd.print(" ))");
lcd.setCursor(2, 2);
lcd.print(" |~~|");
lcd.setCursor(0, 3);
lcd.print("C|__|");
}
void displayRollingCigarette(int frame) {
// Display the rolling cigarette (ASCII art)
for (int i = 0; i < 4; i++) {
lcd.setCursor(frame, i);
if (i == 0) {
lcd.print(" ( ) ");
} else if (i == 1) {
lcd.print(" ) (/ ");
} else if (i == 2) {
lcd.print(" ________________ ( /) ");
} else if (i == 3) {
lcd.print("()__)____________)))) ");
}
}
// If the bottom part of the cigarette goes behind the display, hide it
if (frame >= 12) {
for (int i = 2; i < 4; i++) {
lcd.setCursor(frame, i);
lcd.print(" ");
}
}
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1