Running parallel and I2C LCDs in one sketch

I realise that this is a bit minority-interest, but I am trying to put together a tester for my large heap of various LCD displays. This tester (based on a standard Nano) outputs a screen of useful information to show if an LCD display is communication, and has no defects.

I got the parallel interface LCD tester working very quickly, based on the very helpful "LCD Test Bench" by Floris Wouterlood (Arduino LCD test bench – thesolaruniverse). BTW there seems to be a naughty link there somewhere which pops up dodgy looking advertisements after a while viewing that page.

But I want to output a similar I2C test routine at the same time, and I cannot find any way of having both libraries loaded into the IDE.
I can do a sketch using LiquidCrystal_I2C, or another one using the original LiquidCrystal. Both work fine, as expected. But I cannot combine the two, as they use identical syntax.
Most libraries seem to be for standard OR I2C, and the excellent hd44780 library is very flexible but requires a "case" to be set at the outset to define which display you are dealing with.

I would not mind having a switch that is sensed to swap between parallel and I2C on boot-up if that is somehow easier.
Does anyone have any hints for me so I can put this little project to bed?

Many thanks

You are kidding, yes?

#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
LiquidCrystal_I2C lcd_i2c(0x27, 16, 2);

void setup() {
  lcd.begin(16, 2);
  lcd_i2c.begin(16, 2);

  lcd.print("hello, parallel!");
  lcd_i2c.print("hello, i2c!");
}

void loop() {
}

1 Like

Light bulb moment! I thought both libraries only used lcd.print. I had missed the use of lcd_i2c! I am too much of an Arduino newbie to know this fascinating fact.
Huge thanks - I am off to try this out...

You can call a variable pretty much whatever you like. I could have just as easily called them lcd1 and lcd2, lcd_parallel and lcd_i2c, or x and y. But don't do that last one. :slight_smile:

All working now. I just had to understand the need for different variable names for the two devices.
Your help is very much appreciated.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.