#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
int pre_data = "";
void setup() {
// put your setup code here, to run once:
lcd.init();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int data = analogRead(A0);
//設定第1行顯示:
lcd.setCursor(0, 0);
lcd.print("A0 = "); //顯示文字
lcd.print(pre_data); //顯示文字
//設定第2行顯示:
lcd.setCursor(0, 1);
lcd.print("A0 = "); //顯示文字
lcd.print(data); //顯示文字
//Print同步顯示:
Serial.print("A0 = ");
Serial.println(data);
pre_data = data;
delay(150);
}