#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_ROWS 4
int pot = A0;
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_ROWS);
DHT dht(2, DHT22);
void setup() {
pinMode(pot, INPUT);
lcd.init();
lcd.backlight();
dht.begin();
/*
lcd.print("ahoj");
lcd.print("cau");
lcd.setCursor(10,1);
lcd.print("10 1");
*/
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.println(humidity);
lcd.setCursor(0, 0);
lcd.print(temperature);
lcd.print("C");
lcd.setCursor(14, 0);
lcd.print(humidity);
lcd.print("%");
int potValue = analogRead(pot);
int mPotValue = map(potValue, 0, 1023, 0, 80);
if(mPotValue <= 20){
lcd.setCursor(mPotValue, 0);
lcd.cursor();
}else if(mPotValue > 20 && mPotValue<=40){
lcd.setCursor(mPotValue -20, 1);
}else if(mPotValue > 40 && mPotValue<=60){
lcd.setCursor(mPotValue -40, 2);
}else if(mPotValue > 60 ){
lcd.setCursor(mPotValue -60, 3);
}
lcd.cursor();
}