Addressing two devices in one call

I have two LCD's (typical i2c 1602's). Currently one is connected as lcd. and I send commands as lcd.print(....

If I wanted to add the other LCD to the same i2c bus I know the addresses needed to be unique. Let's assume they are.

If the library allows it, maybe I could init each LCD as

LiquidCrystal_I2C lcd1(0x27, 16, 2);
LiquidCrystal_I2C lcd2(0x3D, 16, 2);

but then every thing I did would need to be duplicated.

So, is there a way to uniquely initialize each lcd as, say, lcd1 and lcd2, but make calls to just lcd.print and have the code deliver the command to lcd1 and lcd2 in simultaneously?

Thanks

you can simply write a function:

void printToDisplays(const char* message, byte column, byte row)
{
  lcd1.setCursor(column, row);
  lcd1.print(message);
  lcd2.setCursor(column, row);
  lcd2.print(message);
}

you can even overload it for other types....

void printToDisplays(int value, byte column, byte row)
{
  lcd1.setCursor(column, row);
  lcd1.print(value);
  lcd2.setCursor(column, row);
  lcd2.print(value);
}

Excellent. I'll sniff the i2C address (and hope its different) and give this a try. Thanks

Some I2C LCDs allow you to change the I2C address.

Pete

el_supremo:
Some I2C LCDs allow you to change the I2C address.

Pete

Or, you may have to add or remove a solder blob across 2 pads, like mine.

el_supremo:
Some I2C LCDs allow you to change the I2C address.

Very common for them to have a jumper that permits you to pick between two. There are also i2c devices that sit on the bus and remap addresses.

There are also i2c devices that sit on the bus

Do they have to have tickets? :grin:

edgemoron:
Do they have to have tickets? :grin:

Only if the collectors are open and the driver is enabled.