#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
uint8_t smiley[8] = {
0b00000,
0b01010,
0b00000,
0b00100,
0b00100,
0b10001,
0b01110,
0b00000,
};
void setup() {
lcd.init();
lcd.backlight();
lcd.createChar(1, smiley);
lcd.begin(16, 2);
}
int currentPosition = 0;
int flag = 1;
void loop() {
if (flag) {
flag = 0;
lcd.setCursor(24,0);
lcd.print("Hello world! \x01");
}
currentPosition++;
if (currentPosition == 40) {
lcd.clear();
lcd.setCursor(24,1);
lcd.print("Hello world! \x01");
}
if (currentPosition == 80) {
lcd.clear();
lcd.setCursor(24,0);
lcd.print("Hello world! \x01");
currentPosition = 0;
}
lcd.scrollDisplayRight();
delay(100);
}