connecting an I2C-LCD without knowing the exact model

hi,

i want to use different LCD displays on my NANO, without the need of changing the code every time.

#include "Wire.h"
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 4 line LCD

void setup() {
  // start LCD
  lcd.begin(20,4);
  lcd.backlight();
  lcd.setCursor(0,0);
  lcd.print("hello");
}

void loop() {
}

What if my friend wants to connect an LCD display with address 0x2F to my NANO?

I tried to use the i2c address scanner, but LiquidCrystal_I2C lcd needs to be declared before setup(), so that did not get me any further.

what are my friend’s options here? :wink:

wowi:
what are my friend's options here? :wink:

  • Change the code.
  • Have you change the code.
  • Buy an LCD that matches yours.

Have you tried the I2CLCDGuesser?

thanks for your answers,

i2CLCDGuesser does not help in my case

for now i just stick to johnwasser's "Buy an LCD that matches yours." :slight_smile:

just in case someone else comes across this problem:

My plan B would be to create multiple instances of LiquidCrystal_I2C using the most common addresses for these LCD displays and then just send my lcd.prints to ALL of them.
This is not elegant and probably quite space consuming , and I have not even tried it myself

wowi:
My plan B would be to create multiple instances of LiquidCrystal_I2C using the most common addresses for these LCD displays and then just send my lcd.prints to ALL of them.
This is not elegant and probably quite space consuming , and I have not even tried it myself

That is what I2CLCDGuesser does. There is a better library and tools called hd44780 and has an even better LCD "guesser".