#include <dht.h>
#include <LiquidCrystal_I2C.h>
dht DHT;//connected to pin 2
LiquidCrystal_I2C lcd(0x27, 20, 2);//lcd init
//red let heater, blue led humidifier
void setup() {
// put your setup code here, to run once:
asm(".equ DDRB,0x04\n"// init ddrb
".equ PORTB, 0x05\n"// int portb
"ldi r16,0b00000110\n"
"out DDRB,r16\n"//set output pins
);
Serial.begin(9600);//start reading from dht-22 sensor
lcd.init();
lcd.backlight();
}
void loop() {
//output
DHT.read22(2);
float Humidity = DHT.humidity;
float Temperature = DHT.temperature;
//temp 35-36.9, hum 35-55
if(Temperature < 35.0)//lcd display brokes this function
{
asm("ori r31, 0b00000010\n"//open heater
"out PORTB, r31\n");
}
if(Humidity < 35.0)
{
asm("ori r31, 0b00000100\n"//open humidifier
"out PORTB, r31\n");
}
if(Temperature > 36.9 )
{
asm("andi r31,0b11111101\n"//close heater
"out PORTB, r31\n");
}
if(Humidity > 55.0)
{
asm("andi r31,0b11111011\n"//close humidifier
"out PORTB, r31\n");
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humidity:");
lcd.print(Humidity);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp:");
lcd.print(Temperature);
lcd.print("C");
delay(2000);
// put your main code here, to run repeatedly:
}