#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define i2caddr 0x27
LiquidCrystal_I2C lcd(i2caddr, 16, 2);
int col = 0;
int row = 0;
bool back = false;
byte smileyFace[8] = {
0b00000,
0b01010,
0b01010,
0b00000,
0b10001,
0b01110,
0b00000,
0b00000
};
byte cruz[8] = {
0b00000,
0b00100,
0b11111,
0b00100,
0b00100,
0b00100,
0b00100,
0b00000
};
byte calavera[8] = {
0b11111,
0b10001,
0b11011,
0b11011,
0b10001,
0b10101,
0b01010,
0b01110
};
byte feto[8] = { //era un pacman pero no salio xd
0b00000,
0b00000,
0b01100,
0b10110,
0b11000,
0b11101,
0b11110,
0b01100
};
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
lcd.init();
lcd.clear();
lcd.backlight();
lcd.createChar(0, smileyFace);
lcd.createChar(1, cruz);
lcd.createChar(2, calavera);
lcd.createChar(3, feto);
}
void loop() {
String message = "1";
String messagef = "FIJO!";
int msglen = message.length();
lcd.clear();
if (col < 16 - msglen && !back) col++;
else if(col >= 16- msglen) back = true;
if (col > 0 && back) col--;
else if (col <= 0) back = false;
lcd.setCursor(col,0);
lcd.write(byte(0));
lcd.setCursor(0,0);
lcd.write(byte(1));
lcd.setCursor(16-col,1);
lcd.write(byte(2));
lcd.write(byte(3));
delay(100); // this speeds up the simulation
}