#include <LiquidCrystal.h>
#include"DHT.h"
LiquidCrystal lcd(12,11,10,9,8,7);
const int PINDHT =5;
const int DHTTYPE = DHT22;
int hour=1;
int dong =1;
DHT dht(PINDHT,DHTTYPE);
struct danhsach{
float nhietDo;
float doAm;
danhsach* next;
};
danhsach* h= NULL;
void setup()
{
Serial.begin(9600);
lcd.begin(20,4);
dht.begin();
}
void docCamBien()
{
danhsach* p=new danhsach();
p->doAm=dht.readHumidity();
p->nhietDo=dht.readTemperature();
p->next=NULL;
if( h==NULL) h = p;
else h->next = p;
if(dong>3) dong=1;
lcd.setCursor(6,0);lcd.print(" doAm");lcd.print(" nhietDo");
lcd.setCursor(0,dong);
lcd.print("hour");lcd.print(hour);
lcd.setCursor(7,dong);
lcd.print(p->doAm);
lcd.setCursor(13,dong);
lcd.print(p->nhietDo);
delay(1000);
dong++;
}
void loop() {
int time = millis();
if(time>hour*1000)
{
docCamBien();
hour++;
}
if(hour>24)
{
danhsach* p=h;
h=h->next;
delete p;
}
}