42 lines
649 B
Arduino
42 lines
649 B
Arduino
|
#include <dht11.h>
|
||
|
|
||
|
int pin_disp = 2;
|
||
|
int pin_dht = 5;
|
||
|
int pin_led_red = 7;
|
||
|
int pin_led_grn = 8;
|
||
|
int pin_disp_clk = 2;
|
||
|
int pin_disp_dio = 3;
|
||
|
|
||
|
dht11 DHT11;
|
||
|
|
||
|
|
||
|
void setup() {
|
||
|
Serial.begin(9600);
|
||
|
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
int chk = DHT11.read(pin_dht);
|
||
|
int humd = (float)DHT11.humidity;
|
||
|
int temp = (float)DHT11.temperature;
|
||
|
|
||
|
Serial.println();
|
||
|
Serial.print("Humidity (%): ");
|
||
|
Serial.println(humd, 2);
|
||
|
Serial.print("Temperature (C): ");
|
||
|
Serial.println(temp, 2);
|
||
|
|
||
|
if(temp >= 21) {
|
||
|
digitalWrite(pin_led_grn, HIGH);
|
||
|
digitalWrite(pin_led_red, LOW);
|
||
|
} else {
|
||
|
digitalWrite(pin_led_red, HIGH);
|
||
|
digitalWrite(pin_led_grn, LOW);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
delay(2000);
|
||
|
}
|
||
|
|