#include "DHT.h"
#include <LiquidCrystal_I2C.h>
#define DHTPIN 2
#define DHTTYPE DHT22
#define potentiometer_R A0
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x27,16,2);
LiquidCrystal_I2C lcd_2(0x28,16,2);
LiquidCrystal_I2C lcd_3(0x29,16,2);
void setup() {
// put your setup code here, to run once:
//potentiometer_R
pinMode(A0, INPUT);
//lcd1602
Serial.begin(9600);
Serial.println(F("start"));
dht.begin();
// Init ICD1
lcd.init();
lcd.backlight();
// Init ICD2
lcd_2.init();
lcd_2.backlight();
// Init ICD3
lcd_3.init();
lcd_3.backlight();
// light
pinMode(4, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
//Before reading, the lamp will light up yellow
digitalWrite(4, HIGH);
delay(275);
digitalWrite(4, LOW);
delay(200);
// Print something Humidity
lcd_3.setCursor(0,0);
lcd_3.println("Humidity:");
lcd_3.setCursor(0,1);
lcd_3.println(h);
// Print something Temperature
lcd_2.setCursor(0,0);
lcd_2.println("Temperature:");
lcd_2.setCursor(0,1);
lcd_2.println(t);
int value = analogRead(A0);
delay(100);
// Print something potentiometer
lcd.setCursor(0,0);
lcd.println("potentiometer:");
lcd.setCursor(0,1);
lcd.println(value);
//Temperature lighting
//The red light indicates that the temperature is higher than 26
//The green light indicates that the temperature is moderate, between (20 to 26)
//The white light indicates that the temperature is cold, below 20
if(t>26)
{
digitalWrite(7, HIGH);
delay(275);
digitalWrite(7, LOW);
delay(200);
}
if(t>20 and t<60)
{
digitalWrite(8, HIGH);
delay(275);
digitalWrite(8, LOW);
delay(200);
}
if(t<20)
{
digitalWrite(13, HIGH);
delay(275);
digitalWrite(13, LOW);
delay(200);
}
}