2-Wire LCD Interface for Arduino or Attiny (updated June 2016)




About: I am a physician by trade. After a career in the pharmeceutical world I decided to take it a bit slower and do things I like. Other than my hobbies that involves grassroots medicine in S.E.&P Asia. I have bu...

LCD's generally need 11signal lines + 3 or 5 lines for Vcc, ground and contrast and in some cases an extra 2 for background light.

Using the LCD in 4 bit mode saves 4 pins, but often that is not enough. Although it is possible to use an I2C module to control the LCD with two wires via the I2C port, there are situations in which that is unpractical, e.g. when u need al analog ports and cant sacrifice A4 and A5 for SDA and SCL.

In that case using a shift register can be a solution.

I am using a 74164 shift register with only a few additional components to do what I need and it can easily be put on a piece of stripboard

2x1k resistor
1x1k variable resistor

The stripboard version follows the standard lay-out for most LCDs with a SIL pin lay-out. However, I also had an LCD, a Seiko M1602, that had a two line pin lay-out for which i made a dedicated version.

For the program I use the LCD library from Malpartida.

#include <LiquidCrystal_SR>
LiquidCrystal_SR lcd(8,7,TWO_WIRE);
//                   | |
//                   | \-- Clock Pin<br>//                   \---- Data/Enable Pin<br>void setup(){
lcd.begin(16,2);               // initialize the lcd<br>lcd.home ();                   // go home
void loop()<br>{<br>lcd.home ();
lcd.setCursor (0, 1 );
lcd.print("2 wire");<br>}

There u go.
Just one more thing. In mu circuit I feed the backlight directly from a 5Volt voltage through a resistor. But as you can see the Shift register still has empty pins. I believe pin 4 carries the backlight on/off signal and if you'd like you could pick up the signal from there, feed that to a BC547 that then can switch the backlight on and off by software.
On the "Next" page I will discuss how to make this work for an Attiny85

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 2-Wire LCD for an Attiny85

If there is a chip that will benefit from needing only 2 pins for the LCD, it is the 8 pin Attiny85/45/25. With pins being reserved for power supply and reset, there are in fact only 5 pins left to use. and though it is possible to implement an I2C protocol in that chip, using a shift register is probably easier.

In its most basic setting the Attiny85 only needs one pull-up resistor.

In order to use the Attiny with the Arduino IDE you need to install an attiny core. I presume that to be well known to most people working with an attiny. However, not all cores are equal and some will give you error messages when using specific libraries or functions. The 'print.h' override is a known one when using print statements or libaries on the attiny. Though that is easy to correct in the print.h and print.cpp files but chances are then an error will pop up in another core file like the hardwareserial.h.

it is easier to use a core that is known to work. The Attiny corefrom David Mellis works in this setting.

A program would look like this:

#include <LiquidCrystal_SR.h>
LiquidCrystal_SR lcd(0,2,TWO_WIRE);
//                   | |
//                   | \-- Clock Pin
//                   \---- Data/Enable Pin<br>void setup(){
  lcd.begin(16,2);               // initialize the lcd
  lcd.home ();                   // go home
  lcd.print("LCD with 2 wires");
  lcd.setCursor ( 0, 1 ); // go to position
  lcd.print("on Attiny85");
}<br>void loop(){

By no means do I want to claim my work in this is original: the core is not mine, the library is not mine and the idea of using a 164 shift register is not mine. I just pull it together here in a practical, working example.

Just a remark. Althoigh I removed the 'br' linebreak html codes a dozen times from the program listing, they keep coming back. So if you copy this program make sure you replace any br codes (the ones between the 'fish hooks') by a linebreak

I noticed some problems that can occur if you are using the I2C port on the Attiny85 via the TinyWireM library as I was unable to read a BMP180 sensor. I have not pinpointed the cause yet. However, if you are implementing an I2C protocol on your Attin85, there is not much reason to use the SR backpack for your LCD anymore. Better use I2C then

Step 2: Two Wires 8 Bit

8 bit Two wires

Previous circuits are all for LCD in 4 bit mode as that is the most often used mode. However, Mike MacLaren pointed me to a circuit that uses a shiftregister (either a 164 or a 595) that uses two wires and does full 8 bit addressing of the LCD

Two Wire 8bit LCD with 164 Shiftregister Two Wire 8bit LCD with 164 Shiftregister[/caption]

The above circuit uses an HC164 shiftregister, but Mike's site also has a circuit for a 595 and a driver program for a PIC as well as an Arduino microprocessor. This circuit does not cater for software backlight control, but it has full 8 bit control, should you need that

1 Person Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

18 Discussions


1 year ago

thanks diy_bloke. Just a note on the BOM. thinks 1N14148 should be 1N4148

1 reply

4 years ago on Introduction

I'm trying to make this work with an ATTiny85, but when I try to use the code, I get an error that there is no wire.h file. Would you please tell me where to get the wire library?

5 replies

Reply 4 years ago on Introduction

That is odd, as the Wire library should be included with your Arduino install.
But you may check here: https://code.google.com/p/arduino/source/browse/t...
But are you sure you selected the right lcd library? Coz as far as I know wire.h is not necessary for this.
Make sure you check yr sketchbook/libraries folder to see if you maybe still find the wire library there.
I use the LCD library from Francisco Malpertida


Reply 4 years ago on Introduction

I got the libraries straight with your help. Everything compiles regarding wire.h, etc. When I bought the shift register ICs, I didn't realize that I got the 74LS164N version instead of the 74LS164 version. I cannot find out what the difference is anywhere. TI has a very nice datasheet for the 74LS164 version, but I cannot find an equivalent for 74LS164N. Do you know if there is a difference? If so, are there any tweaks that could make the N version work? I really want to get this working--I'll buy the non-"N" version, if I have to.


Reply 4 years ago on Introduction

I am not entirely sure but I think the N only refers to the package. Fairchild has a datasheet mentioning the 'N' version:



Reply 4 years ago on Introduction

Thanks for the quick response. I've made a big mess out of my libraries and will try to make it more organized or go to a different PC altogether. In my efforts, I have run into issues with LiquidCrystal_SR.h calling LCD.h calling Arduino.h (which I don't have, either). I am now using new_liquidcrystal which has a bunch of header files. Eventually, I want to do your Mini Weather Station project, but there I am in trouble with manchester.h and can only find MANCHESTER.h. Oh my! I have been successful with using RF RX and TX for temperature on a combination of arduino nano and arduino mini, but I want to do it with the ATTiny85--like you do it. I'll try to set up on a different PC, and get my libraries straight. If all else fails, I'll use my Ubuntu box and try it there. I'll likely be back for more advice.


Reply 4 years ago on Introduction

sorry for my late response on this one, but somehow i seeemd to have overlooked it. The Arduino.h comes with the arduino install package so ineed it seems like you made a bit of a mess, but i understand u have it sorted out now.

I found a circuit for you: http://i557.photobucket.com/albums/ss11/rar0n/Electronics/Arduino/LCD_4-bit_serial_converter_2-wire-latching.png

Martin, in principle yes, but it won't be a 1 on 1 swap as they are not pin compatible.. The New LCD library of Francisco Malpertida works with HC595 as well.
I must say though that most circuits I have seen with a 595 require 3 pins, even the Adafruit LCD backpack.
But if you specifically want to use a 595, then consider using it as a ONE wire interface:



Reply 4 years ago

Ok.. its only because i dont know where to get an 74LS164 shift register. If i enter at amazon i get only the 74HC595N as a reply. The other one seems unknown...

that surprises me. Maybe amazon doesnt have it because it is slightly less popular than the 595. Mercateo in Österreich has it, but they are quite expensive with sending.


You can find 10 of them for 3 euro's (or a 100 of them for a bit more) at Aliexpress:


Could probably find them in any electronic shop in Österreich but as it will cost you maybe 3 euro's in gas and parking, I'd pick delivery from aliexpress