1 changed files with 70 additions and 0 deletions
@ -0,0 +1,70 @@ |
|||||||
|
// https://www.youtube.com/watch?v=-AvF2TsB2GI&list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP&index=50
|
||||||
|
// https://www.youtube.com/watch?v=ep7uBz43fCI&list=PLGs0VKk2DiYw-L-RibttcvK-WBZm8WLEP&index=51
|
||||||
|
|
||||||
|
|
||||||
|
#include <Arduino.h> |
||||||
|
|
||||||
|
#include <Adafruit_Sensor.h> |
||||||
|
#include <DHT.h> |
||||||
|
// #include <DHT_U.h>
|
||||||
|
|
||||||
|
#include <LiquidCrystal.h> |
||||||
|
|
||||||
|
const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12; |
||||||
|
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); |
||||||
|
|
||||||
|
#define DHTTYPE DHT11 |
||||||
|
#define DHTPIN 2 |
||||||
|
|
||||||
|
DHT dht(DHTPIN, DHTTYPE); |
||||||
|
|
||||||
|
float humidity; |
||||||
|
float tempC; |
||||||
|
float tempF; |
||||||
|
|
||||||
|
int setTime = 500; |
||||||
|
int dt = 1000; |
||||||
|
|
||||||
|
|
||||||
|
void setup() { |
||||||
|
// put your setup code here, to run once:
|
||||||
|
Serial.begin(9600); |
||||||
|
Serial.println("DHT11 test!"); |
||||||
|
|
||||||
|
dht.begin(); |
||||||
|
delay(setTime); |
||||||
|
|
||||||
|
lcd.begin(16, 2); |
||||||
|
lcd.print("Hello, World!"); |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
void loop() { |
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
humidity = dht.readHumidity(); |
||||||
|
tempC = dht.readTemperature(); |
||||||
|
tempF = dht.readTemperature(true); |
||||||
|
|
||||||
|
Serial.print("Humidity: "); |
||||||
|
Serial.print(humidity); |
||||||
|
Serial.print(" Temperature: "); |
||||||
|
Serial.print(tempC); |
||||||
|
Serial.print(" *C "); |
||||||
|
Serial.print(tempF); |
||||||
|
Serial.println(" *F"); |
||||||
|
|
||||||
|
lcd.clear(); |
||||||
|
lcd.setCursor(0, 0); |
||||||
|
lcd.print("Humidity: "); |
||||||
|
lcd.print(humidity); |
||||||
|
lcd.print("%"); |
||||||
|
|
||||||
|
lcd.setCursor(0, 1); |
||||||
|
lcd.print("Temp: "); |
||||||
|
lcd.print(tempC); |
||||||
|
lcd.print("oC "); |
||||||
|
delay(dt); |
||||||
|
lcd.clear(); |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue