X
X
Xmaks612021-10-13 17:20:51
LCD displays
Xmaks61, 2021-10-13 17:20:51

Arduino Lcd how to change the data on the screen?

How to switch data by pressing a button, I have temperature, humidity, etc. on the screen, but I want to make it change to other readings from other sensors by pressing, but the code is nadristan.

#include
#include
#include
#include
#include
#define BTN1 6 // button connected here (PIN --- BUTTON --- GND)
#define BTN2 7
#include
Adafruit_BMP085 bmp;
#include "GyverButton.h"

GButton butt1(BTN1);
GButton butt2(BTN2);

DHT dht(4, DHT22);
LiquidCrystal_I2C lcd(0x27,4,5); // set the LCD address to 0x27 for a 16 chars and 2 line display
DS3231 rtc(SDA, SCL);

void setup()
{
Serial.begin(9600);
rtc.begin();
if (!bmp.begin()) {

while (1) {}
}
dht.begin();
lcd.init(); // initialize the lcd



}

void loop()
{
butt1.tick(); // obligatory processing function. Should be constantly polled
butt2.tick(); // obligatory processing function. Should be constantly polled

if (butt1.isClick());
{
lcd.clear();
dht.read();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(dht.getTemperatureC());
lcd.setCursor(5,0);
lcd.print("C");
lcd.backlight();
lcd.setCursor(0,1);
lcd.print(dht.getHumidity());
lcd.setCursor(5,1);
lcd.print("H");
lcd.backlight();
lcd.setCursor(8,0);
lcd.print(bmp.readPressure());
lcd.setCursor(14,0);
lcd print("pa");
lcd.backlight();
lcd.setCursor(8,1);
lcd.print(bmp.readAltitude());
lcd.setCursor(14,1);
lcd print("m");
}
if (butt2.isClick());
{
lcd.clear();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("111111");
}
Serial.print(rtc.getUnixTime(rtc.getTime()));

}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question