LCD Contrast With a Diode

Some very long time ago I read something about using a diode forward voltage to feed v0 for LCD contrast. I tried it forthwith, and indeed it worked for me, too! Now it may well be that not all LCD look great at 0.65V on v0. YMMV

I believe I have found where I read that, if memory serves, at good ol’ Ray’s Hobby. Also known (by me at least) for the AASaver.

Speaking of AASaver, I fried mine. 🙁 Time to get a new one, and perhaps a part or two to fix the other one.

Arduino LiquidCrystal library

RGB backlight, negative display LCD
RGB LCD

As I’ve been progressing on the sous vide controller, I’ve been playing with the LCD 16×2 character display screen that I’m going to put on it. It’s a negative display, RGB backlighted steal of a deal from Amazon.

In this process I got interested in ways to drive the LCD, things like using shift registers and even this amazing Shift1 system to control a whole LCD through a shift register with 1. single. pin. Rather than download various hacked libraries from different sources, I wanted a “standard” library that yet supported all these methods. I wanted support for latching shift registers, registers without latches, and of course shift1, all in the “standard” lib.

So, I did some minor refactoring of the arduino core LiquidCrystal library and extended it with a few more constructor options. You can pass it 3 pins to use a latching shift register where everything goes through the register using just shiftdata, shiftclock, and shiftlatch. You can also pass it a separate enable pin, for 4 pins total, which should speed things up marginally as it doesn’t have to shift the whole register for each LCD enable clock edge up and down. And of course you need that enable pin to use a non-latching register (or a latching register with latch tied to clock), and you can pass 255 as the shiftlatch pin and the library won’t try to use another pin for it.

Then there’s my favorite, the callback function method. You simply define a function that takes three uint8_t types, value, mode, and nbits. The value parameter is the bits the library wants to pound into the LCD, the mode is what it wants the RS pin set to, and nbits is just somewhat of a sanity check, but you can safely ignore it if your function assumes the same nbits that you passed to the constructor. You could write a single function that can do either 4 bit or 8 bit mode, and checks nbits to do either one.

Here’s an example of just how easy it is to use the callback, as well as a link to the github project. If you just use the shift1 library, your custom callback can easily call into the shift1 library to drive your LCD, no need for hacking shift1 directly into the LCD library!