#include <DHT.h>
#include <Wire.h>//I2C uno
#include <LiquidCrystal_I2C.h> //LCD_I2C
#define DHTPIN 8
#define DHTTYPE DHT22
DHT d123 (DHTPIN, DHTTYPE);
LiquidCrystal_I2C L3( 0x27, 20, 4);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
d123.begin();
L3.init();
L3.backlight();
L3.setCursor( 5 , 0 ); // 行 列
L3.print("Holl World!!"); //文字顯示夾在""
L3.setCursor(1,1);
L3.print("===========");
}
void loop() {
// put your main code here, to run repeatedly:
float h = d123.readHumidity();
float t = d123.readTemperature();
Serial.print("Humi= ");
Serial.print(h);
Serial.print(", Temp= ");
Serial.println(t);
L3.setCursor( 2 , 2 );
L3.print("Humi= ");
L3.print(h);
L3.print("%");
L3.setCursor( 3 , 3 );
L3.print("Temp= ");
L3.print(t);
L3.print((char)223); //LCD顯示器字符集中的ASCII 223字符
L3.print("C");
delay(2000);
}