Development notes for LCD4Bit library

A strange 4-bit initialisation gotcha

The only significant difficulty I had when writing the 4-bit mode library came in initialisation. My product-specific datasheet showed an initialisation procedure which in hindsight I think can only be run once, immediately after power on of the LCD. The documented HD44780 init on the other hand can be run at any time. Why is this important? Well, if you have only pressed reset on your arduino board, your LCD may have retained power and will in that case reject the power-up-only init steps your rebooted arduino now sends.

Why is it that this is a 4-bit-specific problem? Well, actually, it's not. The same situation will occur when you're doing 8-bit initialisation. However, the LCD will initialise automatically into 8-bit mode, whether you get things right or not. Only when you're trying to send data in 4-bit mode does it REALLY matter whether your initialisation runs or not. Well, that's not perfectly true. If the LCD understands it is in 1-line display mode and you send data at a line-2 cursor position, you may get gobledegook too, but that's a setting you can change at any time.

There's a more general newbie problem here of pressing reset on your arduino and thinking you've cleanly cycled the power on your entire circuit.