#include <LiquidCrystal_I2C.h>
#define COLS 16
#define ROWS 2
LiquidCrystal_I2C lcd(0x27, 16, 2);
void lcdCenterPrint(const String text, const byte row = 1)
{
if(row <= ROWS && text.length() <= COLS)
{
lcd.setCursor((COLS - text.length()) / 2, row - 1);
lcd.print(text);
}
else lcdCenterPrint("Error!", row);
}
void setup()
{
lcd.begin(16, 2);
lcd.backlight();
//lcd.setCursor(1, 0);
//lcd.print("Hello, Everyone");
//lcd.setCursor(2, 1);
//lcd.print("It's a Test!");
lcdCenterPrint("Hello, World!ffffffffffffffffffffff");
lcdCenterPrint("Hello, World!", 2);
}
void loop()
{
}