LCD 16x4 Hotswap

Hello, I searched on here without luck.

I want to be able to hotswap my 16x4 Hitachi compatible LCD. I tried with the simple hello world example, but it does not work, obviously the display is not initialised.

Putting lcd.begin() in the loop somehow, maybe after checking the press of a button, would be a good way to solve this or should I do it differently?

That sounds a pretty effective way to kill a LCD.

And a 16x4 is a pretty unusual display.

First off, you should ensure that the pins never get high or reverse voltages. Then you should initialise the LCD controller in the usual way.

Yes, you could detect whether a device is present or not.


And a 16x4 is a pretty unusual display.

Unusual (and uncommon) enough that the LiquidCrystal library does not deal with the cursor positioning for the bottom two rows correctly.


In order to do it using all the hd44780 pins in a "live" system, I would recommend using some sort of maintenance mode that can interface with some external hardware to properly control the power so the display can be removed and replaced while the power is disabled and the arduino pins used to interface to the lcd are disabled.

If there a need to detach the display "live", then I'd look at using some sort of serial interface. Perhaps something as simple as an intelligent backpack with an async serial interface. It could use as little as 3 pins to connect to the main Arduino (power, gnd, serial data) The processor on the backpack would initialize the display when powered up and then update the lcd display from messages received on the serial link. If the application needed to know if the display was there or when it was plugged in, then another pin would be needed to indicate the presence of the backpack/lcd-module.

--- bill


I call “XY problem” yet again.

How about you start by explaining why you would ever want to “hot-swap” displays.

It would make much more sense to drive each display with its own Pro Mini as bperrybap suggests as an “intelligent backpack”.