Answer the question
In order to leave comments, you need to log in
Why is the screen flickering?
Hello. I am trying to display the temperature on the lcd 1602 i2c screen from the bme280 sensor, but when I try to do this, the screen starts to flicker. As soon as I remove the line of code with the output of the temperature, everything starts working fine.
here is the code
#include <iarduino_RTC.h>
iarduino_RTC time(RTC_DS1307);
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme;
LiquidCrystal_I2C LCD(0x27,16,2);
void setup() {
delay(300);
LCD.init();
LCD.backlight();
time.begin();
time.settime(0, 30, 18, 12, 6, 20, 5);
}
void loop() {
if (millis() % 1000 == 0) {
LCD.setCursor(0,0);
LCD.print(bme.readTemperature());
LCD.setCursor(4,1);
LCD.print(time.gettime("H:i:s"));
delay(1);
}
Answer the question
In order to leave comments, you need to log in
bme.readTemperature() takes some time, long enough for the eye to notice the delay. Try to read the temperature into a variable, and then display it on the screen:
float temp = bme.readTemperature();
LCD.setCursor(0,0);
LCD.print(temp );
LCD.setCursor(4,1);
LCD.print(time.gettime("H:i:s"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question