#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define I2C_ADDR 0x27
#define LCD_COLUMNS 20
#define LCD_LINES 4
#define DHTTYPE DHT22
#define DHTPIN 10
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_LINES);
const int buttonPin = 12;
int buttonState = 0;
float h=0;
float t=0;
int n=0;
void setup() {
lcd.init();
lcd.backlight();
pinMode(10, INPUT);
dht.begin();
Serial.begin(9600);
}
void loop() {
buttonState = digitalRead(buttonPin);
while (buttonState == HIGH) {
h = dht.readHumidity();
t = dht.readTemperature();
lcd.setCursor(3, 0);
lcd.print("Hum = ");
lcd.print(h);
lcd.print(" %");
lcd.setCursor(2, 1);
lcd.print("Temp = ");
lcd.print(t);
lcd.print(" C");
lcd.setCursor(0, 3);
lcd.print("№ ");
lcd.print(n=n+1);
delay(3000);
buttonState = digitalRead(buttonPin);
}
lcd.setCursor(8, 1);
lcd.print("Hello");
}