// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
#include <DHT.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
#define Botton 3
#define DHT22_1 4
#define DHTTYPE DHT22
#define DHT22_2 5
//#define DHTTYPE_2 DHT22
volatile int wiersz;
DHT dht(4,DHTTYPE);
//DHT dht_2(5,DHTTYPE);
void setup() {
lcd.begin(16, 2);
pinMode(Botton, INPUT_PULLUP);
pinMode(DHT22_1, INPUT);
pinMode(DHT22_2, INPUT);
attachInterrupt(digitalPinToInterrupt(Botton),przycisk,CHANGE);
dht.begin();
}
void loop() {
// ...
// lcd.setCursor(0,0);
float t = dht.readTemperature();
float h = dht.readTemperature();
lcd.blink();
//if(dht.readStatusString()=="OK")
// {
delay(300);
lcd.print(t);
lcd.print(" C");
//delay(400);
lcd.setCursor(0,1);
lcd.print(h);
lcd.print(" %RH");
lcd.print(" ");
delay(2500);
lcd.clear();
lcd.setCursor(0,0);
delay(2000);
//t= dht_2.readTemperature();
// h = dht_2.readHumidity();
//if(dht.readStatusString()=="OK")
// {
// if(isnan(t) ||isnan(h))
// {
// lcd.print("blad odczytu");
// }
// else{
// lcd.clear();
// lcd.setCursor(0,0);
// lcd.print("Temp: ");
// lcd.print(t);
// lcd.print("C");
// delay(400);
// lcd.setCursor(0,1);
// lcd.print("Wilgotnosc: ");
// lcd.print(h);
// lcd.print(" %RH");
// lcd.print(" ");
// }
// for(int i=0; i<17 ; i++)
// {
// lcd.setCursor(i,wiersz);
// lcd.print(" ");
// lcd.print("Hello");
// delay(200);
// lcd.setCursor(i,wiersz);
// }
// //delay(200);
// lcd.print(" ");
// for(int j=16; j>-1;--j)
// {
// lcd.setCursor(j,wiersz);
// lcd.print(" ");
// lcd.print("Hello");
// lcd.print(" ");
// delay(200);
// lcd.setCursor(j,wiersz);
// }
}
// else
// {
// delay(500);
// lcd.print("Blad odczytu");
// lcd.print(" ");
// lcd.setCursor(0,0)
// }
// delay(dht.readMinimumSamplingPeriod());
//}
void przycisk() //funkcja odpowiadająca za przerzucenie słowa o jeden
//wiersz niżej lub wyżej
{
if(digitalRead(Botton)==false) //jeśli przycisk jest wciśnięty
{
wiersz =!wiersz; //przerzuć wartość wiersza 0 do wiersza 1
lcd.setCursor(0, !wiersz); //ustaw kursor w wierszu różnym od zerowego, czyli o wiersz niżej
lcd.clear(); //czyszczenie lini wiersza
delay(100);
}
}