#include <LiquidCrystal_I2C.h> // 引用 LiquidCrystal_I2C Library
// 設定 LCD 位址為 0x27,有 16 個字元 2 列
LiquidCrystal_I2C lcd(0x27,20,4);
int row=0;
void setup()
{
lcd.init(); // 初始化 lcd
lcd.backlight(); // 設定背板為亮
}
void loop()
{
lcd.clear();
lcd.setCursor(0,row);
lcd.print("hello!");
for(int i=0;i<14;i++)
{
lcd.scrollDisplayRight(); //往右移一格顯示
delay(200);
}
// 判斷目前行數, 是0行,將Row + 1,往下跳一行
for(int j=0;j<3;j++)
{if(row == j){
row = row + 1;
lcd.clear();
lcd.setCursor(14,row);
lcd.print("hello!");
delay(200);
}
}
for(int i=0;i<14;i++)
{
lcd.scrollDisplayLeft(); //往左移一格顯示
delay(200);
}
// 判斷目前行數, 是1行,將Row 改為0行
for(int j=3;j>0;j--)
{
if(row == j){
row = row-1;
lcd.clear();
lcd.setCursor(0,row);
lcd.print("hello!");
delay(200);
}
}
}