Hardware | Price |
---|---|
Arduino Uno R3 開發版 | $139 |
Arduino 壓克力保護盒 | $55 |
9V 電池盒 | $22 |
杜邦線 20公分,母-公 7條 | $10.15 |
Aosong AM2320 | $85 |
LCD 1602 LCM (已焊 IIC底板) | $94 |
紙盒 | $0 |
合計:$405.15 |
Last active
February 16, 2017 06:10
-
-
Save mcdlee/0d051f228b761e7701a6d9a5613799c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "DHT.h" | |
DHT dht; | |
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
dht.setup(2); // data pin 2 | |
lcd.init(); | |
lcd.backlight(); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
//delay(dht.getMinimumSamplingPeriod()*10); | |
lcd.clear() ; | |
lcd.noBacklight(); | |
delay(3000); | |
float humidity = dht.getHumidity(); | |
float temperature = dht.getTemperature(); | |
Serial.print(dht.getStatusString()); | |
Serial.print("\t"); | |
Serial.print(humidity, 1); | |
Serial.print("\t\t"); | |
Serial.print(temperature, 1); | |
Serial.print("\n"); | |
lcd.backlight(); | |
lcd.print(temperature, DEC ); | |
lcd.setCursor(1, 1); | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment