#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to the correct value for your LCD
// This address is an example, you need to replace it with the correct address
#define LCD_ADDRESS 0x27
// Set the number of columns and rows on the LCD
#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.begin();
// Turn on the backlight
lcd.backlight();
// Print initial message
lcd.print("Countdown:");
}
void loop() {
// Countdown from 10 to 0
for (int i = 10; i >= 0; i--) {
// Clear the display
lcd.clear();
// Print countdown value
lcd.setCursor(0, 1);
lcd.print(i);
// Delay for 1 second
delay(1000);
}
}
留言
張貼留言