// LCD2004 Tiny Pacman on Wokwi
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
LiquidCrystal_I2C lcd2(0x27, 20, 4);
uint8_t pacman[8] = {
0b00000,
0b00000,
0b01110,
0b11011,
0b11111,
0b01110,
0b00000,
0b00000
};
uint8_t pacmanOpen[8] = {
0b00000,
0b00000,
0b01110,
0b11011,
0b11100,
0b01110,
0b00000,
0b00000
};
uint8_t dot[8] = {
0b00000,
0b00000,
0b00000,
0b00011,
0b00011,
0b00000,
0b00000,
0b00000
};
/**TRY THIS AND SEE HOW IT WORKS THEN?**/
/*
uint8_t dot[8] = {
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
*/
void setup() {
intro();
}
void intro() {
lcd.createChar(1, pacman);
lcd.createChar(2, dot);
lcd.begin(20, 4);
lcd.setCursor(3, 0);
for (int i = 3; i < 16; i++) {
lcd.setCursor(i, 3);
lcd.print("\1");
for (int j = i + 1; j < 16; j++) {
lcd.setCursor(j, 3);
lcd.print("\2");
}
lcd.createChar(1, pacman);
delay(50);
lcd.createChar(1, pacmanOpen);
delay(50);
lcd.setCursor(i, 3);
lcd.print(" ");
}
delay(1000);
//****** I2c LCD *****//
//CODE COPY-PASTED FROM ABOVE//
//0 CHANGES
lcd2.createChar(1, pacman);
lcd2.createChar(2, dot);
lcd2.begin(20, 4);
lcd2.backlight();
lcd2.setCursor(3, 0);
for (int i = 3; i < 16; i++) {
lcd2.setCursor(i, 3);
lcd2.print("\1");
for (int j = i + 1; j < 16; j++) {
lcd2.setCursor(j, 3);
lcd2.print("\2");
}
lcd2.createChar(1, pacman);
delay(50);
lcd2.createChar(1, pacmanOpen);
delay(50);
lcd2.setCursor(i, 3);
lcd2.print(" ");
}
}
void loop(){};