Introduction: ATTiny45/85 LCD Display Control With a Shift Register, Programmed in Arduino

Picture of ATTiny45/85 LCD Display Control With a Shift Register, Programmed in Arduino

Running Arduino on an ATTiny45 of 85 chip is a huge cost-saver for mini-projects. However, you cannot connect a HD44780 compatible LCD display as you require 6 outputs, but you only have 5. This issue can be solved by using a shift register to control it using only 3 pins! That means you still have 2 more left over for other use!

Step 1: Parts Needed

Here is a list of the parts you will need for this project:

1x Arduino Microcontroller (to act as the programmer, you could use an ISP to program them though.)
1x ATTiny45 / ATTiny85 microcontroller
1x 74HC595 Shift Register
1x HD44780 compatible LCD
1x LED (for testing the microcontroller)
1x Resistor for the LED (use one that is right for the specs of your LED)
1x Potentiometer for LCD contrast (You can connect the contrast to ground 
Loads of wires!

Step 2: Connecting the ATTiny to Arduino

Picture of Connecting the ATTiny to Arduino

The ATTiny pins are numbered in picture 1.

Start by connecting ATTiny pin 4 to Ground.
Connect ATTiny pin 8 to +5V.

Next, connect the following cables from the ATTiny to Arduino:
ATTiny pin 1 to Arduino pin 10,
ATTiny pin 5 to Arduino pin 11,
ATTiny pin 6 to Arduino pin 12,
ATTiny pin 7 to Arduino pin 13.

In some cases such as using the new Uno boards, ou will need to connect a 10 microfared capacitor from the Arduino reset pin to Ground. Make sure the capacitor ground (-) is connected to round as it is polarised. In my case everything works just fine without one, but there may be some issues that I'm not aware of. If anyone is aware of any then please post them in the comments.

You are now good to go, next is the programming!

(reference: High-Low Tech)

Step 3: Programming the ATTiny85 With a Test Program

Picture of Programming the ATTiny85 With a Test Program

** Using Arduino 1.0 IDE with this method doesn't work. Download version 22 or 23 of the IDE and try this method. **

Now that you have finished wiring up the Arduino, it is time to program it.
Start by downloading the hardware support files courtesy of High-Low Tech.
You should have a file called "attiny45_85.zip".
Right now make sure the Arduino IDE is closed before doing the following steps above.
Open your Arduino sketchbook folder and create a new folder called "hardware" inside it. (if it already exists leave it)
Now, unzip the file you downloaded earlier and copy the attiny45_85 folder from the extracted zip into the hardware folder.

Open the Arduino IDE and go to "File", "Examples", and open the "ArduinoISP" sketch. Upload that to your Arduino board.
Now, go to "Tools", "Board" and select either the ATTiny 45 or ATTiny85, with the Arduino as ISP.

Next, load the Blink example from the Examples -> Basics menu. Remember that the ATTiny does not have the same pins as an Arduino board, so refer to the image above. Every time you see pin 13 in the exampls, replace it with a pin of your choice. Simply connect an LED to this pin with an appropriate resistor and connect the ground lead of the LED to Ground.
Simply press "Upload to I/O Board" and the program will be uploaded and the LED should flash!
You may see errors telling you to define PAGEL and BS2 signals but you can ignore these, It works just fine.

At this stage you could remove the chip from the breadboard and power it with 2 AA batteries and it would work on its own.

Step 4: Building the Shift Register LCD Controller

Picture of Building the Shift Register LCD Controller

To build the shift register to LCD circuit, use the schematic found in Image 1 above.
This circuit was not developed by me, but I got it from this blog post.
You can build it on a breadboard, but I soldered it on some board.
You can see some pictures of my board above.

Step 5: Connecting the LCD Controller to the ATTiny

Picture of Connecting the LCD Controller to the ATTiny

To connect the LCD controller to the ATTiny,
Connect Shift Register pin 11 to ATTiny I/O pin 2 (actual pin 7)
Connect Shift Register pin 12 to ATTiny I/O pin 1 (actual pin 6)
Connect Shift Register pin 14 to ATTiny I/O pin 0 (actual pin 5).
Make sure the LCD and shift registers are connected to +5V and Ground (in previous step)

Step 6: Programming the ATTiny With the ShiftLCD Library Code

Picture of Programming the ATTiny With the ShiftLCD Library Code

You will need to install the ShiftLCD Arduino library for the ATTiny. To find out how to get this setup, read here.
Once the library is installed, open the Arduino IDE and load the "HelloWorld" ShiftLCD example from the "Examples", "ShiftLCD" menu.
You will need to modify the pinout for the ATTiny and your shift register. In the part of the code that says the following:

ShiftLCD lcd(2, 4, 3);

Replace it with the following, or whatever pins you connected to the ATTiny:

ShiftLCD lcd(0, 2, 1);

Now all you need to do is upload the program to the ATTiny.

Step 7: Testing!

Picture of Testing!

If everything went to plan, you should now see "Hello World" on your LCD and a counter on line 2 that increments every second.
The ShiftLCD is exactly the same as the built in LiquidCrystal library. All functions are exactly the same and everything works on the ATTiny. However, the speed that the LCD can be written at is slower. It will take about 250ms to fill an entire 2x16 LCD with characters.
However, it is pretty quick for only replacing a few digits with the setCursor function.
I hope this Instructable worked great for you.
If I made any mistakes in the pinouts, I greatly apologize and want you to tell me about the issues.

(disclaimer: I did not create the ShiftLCD library and do not have anything to do with it.)

Comments

Sn34kyP373 (author)2016-04-24

I ran into problems with compiling the referenced ShiftLCD library originally created by Chris Parish. The issue was due to Arduino 1.0 breaking compatibility. This was fixed and made available at this link: https://github.com/Chris--A/ShiftLCD_Fixed

Also, programming ATtiny boards is way more simpler than when this instructable was posted. See http://highlowtech.org/?p=1695 for some info on setup and consider making your own ATtiny programmer shield for Arduino.

jimpeachey (author)2014-03-21

Im having real problems controlling an LCD with anATTiny85 despite following several instructables. Does anyone have a full fritzing diagram for this instructable so that i can see what all the connections are supposed to be? I have been using ATTin85 pins 0 1 and 2 Does the order that you list them in the sketch make any difference? Im also not sure how using different libraries affect the way these things operate so would appreciate any help that anyone could give. Thanks

diy_bloke (author)jimpeachey2014-11-01

it has been a while, and i hope you found the reply, but just in case
someone is looking for the same answers: yes, it does make a difference
what orde you list the pins as the order defines datapin, clockpin, latchpin.
Yr program should look like this:

#include "LiquidCrystal595.h" // include the library or replace the "" by fishhooks
LiquidCrystal595 lcd(0,1,2); // datapin, latchpin, clockpin

void setup() {
lcd.begin(16,2); // 16 characters, 2 rows

lcd.clear();
lcd.setCursor(0,0);
lcd.print("Only 3 pins!");
lcd.setCursor(0,1);
lcd.print("Thats it");
}

void loop() {
// not used.
}

If you want to work with an LCD on a attiny84, I strongly suggest the two wire variant with a 74HC164, saves an extra pin

http://arduinodiy.wordpress.com/2014/01/12/two-wire-interface-for-lcd/

ryuhemanth (author)diy_bloke2015-11-11

Thanks, i really like the 2 - wire option.

diy_bloke (author)ryuhemanth2015-11-12

my pleasure

killercatfish (author)2015-01-19

What would you use as a power source if you wanted this to be stand alone without using the arduino power?

diy_bloke (author)2014-08-18

try making a shiftregister with only two wires

http://arduinodiy.wordpress.com/2014/01/12/two-wir...

... or better yet, only one

http://www.romanblack.com/shift1.htm

Timofte Andrei (author)2014-07-12

i'm wondering if it's possible to make a thermometer using this configuration with a DS18B20 sensor...

jimpeachey (author)2014-03-22

Can i just replace the original sketch command of

LiquidCrystal595 lcd(7,8,9); with

LiquidCrystal595 lcd(0,1,2);

As you can see i am using a different library than this one but i have had it working with a shift register, just not an ATTiny85. Any help would be greatly appreciated.

Krb686 (author)2013-08-07

Very cool project, but you could also just get a 14-pin ATTiny84, which has 11 digitial I/O. I guess it's cool to learn how to add additional pins to micros though.

emdarcher (author)2012-07-23

I used this library and it worked
http://code.google.com/p/arduino-lcd-3pin/

it is used in this instructable
https://www.instructables.com/id/Hookup-a-16-pin-HD44780-LCD-to-an-Arduino-in-6-sec/

diy_bloke (author)2012-01-08

Judging from the website of Chris Parish, quite some people experienced errors with the code

qwerty156 (author)2012-01-07

Would this work on an ATTINY2313

diy_bloke (author)qwerty1562012-01-08

You will find a 2313 core here:
http://hci.rwth-aachen.de/luminet
I have not tried that one, but it may come in handy if the Attin85 core doesn't do it for you

baharini (author)qwerty1562012-01-07

I have not tried with this chip before, but I believe you can run arduino on it.
You can try out the Arduino Tiny core, found at http://code.google.com/p/arduino-tiny/
I know the core will work with the tiny 2313 but I am not completely sure on the ShiftLCD library. It may work just fine, or it will get a compiling error. I wish you good luck!

About This Instructable

74,730views

152favorites

License:

Bio: I'm a software developer, but I also love tinkering with electronics. My Instructables are all about Arduino.
Add instructable to: