i would like to ave a 16x2 LCD i2c address in eeprom, and then on the next boot read it and delcare the LCD according to it.
if i declare:
LiquidCrystal_I2C lcd(0x28, 16, 2);
and then later reed eeprom "address" and redeclare LCD in the setup:
LiquidCrystal_I2C lcd(address, 16, 2);
the main loop lcd.print() commands respond to address 0x28 and not to "address".
any tips how to fix this?
if i declare "LiquidCrystal_I2C lcd(address, 16, 2)" in every cycle of the main loop the LCD works, but it keeps flashing as declearation needs a backlight switch on after it.
Here is an exmaple code.
my LCD address is 0x27.
i purposely init the LCD on 0x3F, and then i want to read address from EEPROM (0x27) and re-init the LCD to 0x27.
but it appears that since i have already initied the object lcd, it stays on address 0x3f.
Test code:
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3f, 16, 2); // wrong LCD address
#include <EEPROM.h>
int arm = 0;
void setup()
{
Serial.begin(115200);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print ("Setup");
delay(500);
}
void loop()
{
if (arm == 0)
{
// read correct LCD address from EEPROM here
LiquidCrystal_I2C lcd(0x27, 16, 2);
lcd.init();
lcd.backlight();
arm = 1;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print (" Loop test ");
delay(500);
}
This code does not print anything on LCD with address 0x27, but if i change the top init to 0x27, it works.
the problem is that my final version Ardu wont know the LCD address its attached to until it scans and finds it, and this is after the LCD init phase.
If you look at the HelloWorld example the comments mention not needing to specify the I2C address, but I don't see it mentioned explicitly in the API for some reason.
david_2018:
If you look at the HelloWorld example the comments mention not needing to specify the I2C address, but I don't see it mentioned explicitly in the API for some reason.
david_2018:
If you look at the HelloWorld example the comments mention not needing to specify the I2C address, but I don't see it mentioned explicitly in the API for some reason.