#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define LCD_ADDRESS 0x27
#define LCD_COLUMNS 16
#define LCD_ROWS 2
// Initialize the LCD
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);
void setup() {
// Initialize the LCD
lcd.init();
// Turn on the backlight
lcd.backlight();
// Print initial message
lcd.print("Hello World!");
}
void loop() {
// Move "Hello World!" message to the left
for (int i = 0; i < LCD_COLUMNS + 12; i++) { // Loop through the number of columns plus length of message
lcd.scrollDisplayLeft(); // Scroll display left
delay(200); // Delay for animation
}
}
留言
張貼留言