#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
}
void loop() {
float humi, temp;
temp = dht.readTemperature();
humi = dht.readHumidity();
if(isnan(humi) || isnan(temp)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("온도 : ");
Serial.print(temp);
Serial.println("C");
Serial.print("습도 : ");
Serial.print(humi);
Serial.println("%");
}
'Development > Arduino' 카테고리의 다른 글
[아두이노]LED Blink (0) | 2020.11.18 |
---|