分享

LCD+DHT11

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
DHT dht11_p3(3, DHT11);
void setup()
{
 Serial.begin(9600);
 dht11_p3.begin();
  lcd.init();                      // initialize the lcd 
 lcd.init();
 // Print a message to the LCD.
 lcd.backlight();
 lcd.setCursor(1,0);
 lcd.print("T:");
 lcd.setCursor(3,0);
 lcd.print(dht11_p3.readTemperature());
 lcd.setCursor(1,1);
 lcd.print("H:");
 lcd.setCursor(3,1);
 lcd.print(dht11_p3.readHumidity());
}
void loop()
{
 Serial.print("溫度:");
 Serial.println(dht11_p3.readTemperature());
 Serial.print("濕度:");
 Serial.println(dht11_p3.readHumidity());
 delay(1000);
}
分類:科技

評論
上一篇
  • 下一篇
  • 更多文章
    載入中... 沒有更多了