Hi!
I managed to put together a library for connecting a LCD with 3 wires from an Arduino. It is basically the same as the LiquidCrystal library, which it is pretty much based on (almost verbatim ) It's just tweaked to work with a shift register. I used 74LS164, since that's what I had. It's not a fancy shiftregister (no tristate nor latching etc.), so I kept the Enable-pin on the Arduino. Thus using three pins from the Arduino. Basically any shiftregister should do.
I'm pretty new to the Arduino, but I have dabbled a little in both electronics and C++ before. But not much, this is the first class or library I've written for C++. Or very C++ like language.
The Morse-tutorial was great, as well as looking into the LiquidCrystal library. It's still a couple of things that seems strange to me in that one, but I finally got the inheritance - I think. The this->write(b); isn't too intuitive. But I think I get it, "this" points to the library who inherits the print-library, and so the write()-function that is used is from that library (LiquidCrystal::write(), for instance). The write() function needs to be declared "virtual" in the header file for this to work.
And there is a strange way of assigning the class instance's global variables in the constructor, the _enable_pin(enable) before the curly parenthesis (I didn't get it to work like that in my version, but I followed the Morse tutorial for that instead).
Since I had an old HD44780 LCD display, I wanted to connect it to the Arduino. Like most of us it seems, so this might be a bit like reinventing the wheel for the n'th time. But I hope this might be useful for some anyway. Plus I learned a bit about classes and libraries in C++
A bit crude, as there is no reading of the busy flag from the LCD. I am however playing with the idea of implementing that while still using the same three connections from the Arduino. That will require some more external circuitry however, and I'm not sure when I will start tinkering with that, so for now I thought I'd share this one.
It does seem a bit sensible to how it starts. For instance, it usually starts well after uploading a sketch, but by pressing the reset-button on the Arduino, it seems to be neccessary to hold the reset-button down for about a second or so. Strange, and not always reliable.
It seems some have 4-line LCD-displays with (I think) common data pins (D0 - D7), and two enable-pins. There should be no problem making two instances of ShiftRegLCD objects with the same data and clock-pins, but with different enable pins, thus using 4 pins on the Arduino.
Btw, the official library starts the LCD in 2-line mode (stating erroneously it is 1 line in the comments, but no biggie). It works nice for my 1 line 32 character LCD, so I kept it that way.
As I had to use one bit for the RS signal, and didn't have any 9-bit shiftregisters handy, I use the LCD's in 4-bit mode. Seems fast enough for most purposes, but wastes 3 outputs on the shiftregister (for now). RW on the LCD is grounded, only writing-to is supported in this.
Of course if anyone wants to improve or alter upon this they are welcome to. After all, the official library is licenced under a Creative Commons Attribution-ShareAlike 3.0 License. I couldn't find that particular license on google code pages, so I used GNU GPLv3, and hope that is similar enough.
Project homepage: Google Code Archive - Long-term storage for Google Code Project Hosting.
If anyone wants to know, this is how I connected my LCD. (I know I should probably used a potmeter for the contrast setting, V5 on the LCD. But it works). Of course it doesn't matter which pins from the Arduino one use. I used pins 8, 12 and 13 here. Also, the one I have tested this with, is a Bare Bones Board with Atmega328 at 16 MHz. But I think it should work with an atmega168 at the same speed or slower without any modifications.
(I know, I mixed block schematics with pinout for the 74xx164)