2-Wire LCD for Arduino and other Projects

The problem with standard 2-line LCDs is that they take AT LEAST 6 lines to control them (2 control, 4 data) – and that’s a problem if you don’t have that many.

2-wire LCDThere’s a lot of info out about reducing the number of leads out there and some of it is confusing… so here is a working example of how to make an adaptor – some day I’ll do a board layout – suffice it to say the diagram is correct – the ONLY thing that is missing – and it’s something that catches amateurs out – is a decoupling capacitor – or phrased another way, a bog-standard 0.1uf capacitor (not an electrolytic).

The research isn’t mine – the library is out there (and it’s a winner) and the diagram is out there, I’ve just put the lot together after a lot of wasted time and effort following notes by people who don’t even understand why you’d need a decoupling capacitor then wondering why it doesn’t work.

2-wire LCDHere’s my prototype on the right, a bit of prototype board underneath a bog-standard 16-character by 2 line display… and here it is on the left in action – note the 4 wires are +5v, ground, clock and data  – that’s it.

The Library is one you should be replacing your standard Arduino library with ANYWAY (simply overwrite)…

For the diagram see here http://code.google.com/p/arduinoshiftreglcd/#Note_about_the_diode-resistor_AND_%22gate%22 it’s the one marked “Bill’s version with a latched shift register”.  This has 2 less resistors than other circuits however it WORKS – keep your wires short and don’t forget that 0.1uf cap from pins 8 and 16 on the chip – as near to the chip as poss. This is essential to reduce electrical noise that might otherwise make the whole thing unreliable. To date this has not failed to continue to run, or failed to start up correctly.

That same link gets you the library as well. The version there is old and the writer points you to here. https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home

I didn’t use his “contrast” pin. I used a 10k preset from ground to +v with the centre slider going to pin 3 on the LCD. If that’s not roughly in the right place (usually at one end) you’ll just see a blank backlit screen. You COULD bring out the backlight + to an Arduino analog output if you wanted to control the brilliance as I did one one project as the backlight got on my nerves overnight (bedroom SAD light timer).

If this was put on a little PCB it could be much smaller than my prototype and through-hole-plating would make for a much stronger connection than I have here – but… it works!

4-line LCD using 2-wire connectionTo prove this wasn’t a fluke (if you read variations of the article I’ve linked to,  people start ranting about different diodes etc., I stuck with the 4148 and the 1k resistor as in the diagram) I made another version (better wiring, no links on the bottom, it gets easier the second time) with a 4-line display from a completely different supplier… worked first time, utterly reliably. The green main board you see is my own Uberduino and 4-line LCD using 2-wire connectionI’m seriously considering adding this circuitry to the next version… for a matter of pennies worth of components you get 4 lines back and less chance of messing up.

Next I’m going to try one of those cheap Nokia graphic displays to see if I can reduce THAT down to 2 lines! If only finding decent project boxes was this simple.

Update: It occurred to me that while using the shift-register solution is certainly neat  it does not solve one problem – the library – also people seem to have to go to ridiculous lengths to make larger fonts (which don’t look nice) for these displays because the technology is ancient (I was using these things, what, 20 year ago?)… so I took a close look at the Nokia displays – the side-lighting on the latter is awful but they are capable of full graphics (ie progress bars etc and larger fonts) but in order to do THAT the libraries generally rely on a memory buffer to hold the bitmap… and that of course eats into your available RAM. In my tests I was down to 500 bytes left after installing real time clock and the graphical library for the display…

I’d been checking on the cost of the 328 chips and it turns out that many suppliers are ripping off the community – charging 3 o 4 £ sterling for a chip – in fact there are UK suppliers who will sell them in small quantities for sub-£2 and at that price you can think of them a just another component. It turns out that the 328 chip can run at 8Mhz without a crystal (ie internal oscillator) and run i2c quite reliably (2-wire interface). Thinking about the benefits of this – all the RAM-consuming graphics can be contained in an inexpensive chip powering the Nokia display (with room for the 2-line displays in there as well), software RTC and more – and you can then just talk to the thing by a simple 2-wire interface.

So, that’s my next project but not until I find out by experiment what the power overhead is in doing it this way… If I can get the chip to wake up on i2c then it should be easy to shut the chip down when it’s not changing the display or updating the clock – but more of that in a future blog.


Peter Scargill

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s