Instructables

Hookup an LCD to an Arduino in 6 seconds with 3, not 6 pins

Picture of Hookup an LCD to an Arduino in 6 seconds with 3, not 6 pins
completed-top-view-sml.jpg
Adding an LCD display to Arduino projects can add real value but the cost of doing so can be significant. Not a financial cost - you can pick up 16 (characters) x 2 (rows) LCD for as little as £3.50. The cost is the pin count it can take to drive them. Using the built-in LiquidCrystal Display library it can take as many as 6 pins! That does not leave much for your sensors, motors and other components.

There are many projects that discuss using alternatives - such as a much more expensive Serial LCD (£10 up). Other projects discuss using two-wire interfaces, increasing the complexity of your code. The simplest way to drive the HD44780 style LCDs, in my opinion, is to use a 74HC595 shift register, taking the pin count down to 3.

In any case, connecting an LCD either using the 595 Shift Register or the more traditional way takes a lot of wiring which is not only a super mess (unless you use a ribbon cable I guess), it takes time.

This shield is simplifies this process - all that is required is power and three wires back to the Arduino - ie. connect the LCD in under 6 seconds!
 
Remove these adsRemove these ads by Signing Up

Step 1: Required Components

Picture of Required Components
This is an extremely easy board to make and should take you no more than 15 minutes to solder up and have running.

Component List
    1 x 74HC595 Shift Register
    1 x BC547 NPN (or MOFSET or similar NPN)
    1 x 10k Trimmer Potentiometer
    6 x Male headers (I used right angle connectors)
    16 x Female headers
    Strip/Vero-board 17 strips x 13 holes (I used 15 for cable support)
    Hookup wire
    Your soldering kit
jimpeachey made it!4 days ago

I finished it! This uses and ATTiny85 replacing the take offs for pins 7, 8,and 9 from the Arduino. I also used pins 3 and 4 from the ATTiny to run two flashing LEDs just to see how it work. This is running off a 4.5v battery pack using AAA batteries. I'm glad i got this done,it's a nice unit!

20140411_195143_zpsvps43hmv.jpg20140411_195211_zpsrbb79uhw(1).jpg
jimpeachey10 days ago

Damn, i built this and it still doesnt work! Im going to re-do the circuit board and try again. I really need this to work as it is going to form the basis for how i display the models i build. Wish me luck. bitterOz, any luck with the ATTiny85 version?

mandu2211 months ago
Good day!

I tried making the circuit in my breadboard, and I'm 100% sure I built it right.

However, I only get black squares on the LCD's first row as an output. Any ideas? :D
bitterOz (author)  mandu2210 months ago
Hi mandu22,

Have you tried:
a) adjusting the contrast?
b) try sending something like
void noDisplay();
void display();
void clear();
void home();
and then writing your text?

zzarbi bitterOz19 days ago

I have the same problem of mandu22 and tried what you say and it still doesn't work. Also a schema would be nice as well, I know this is meant for people with no electrical skills but trying to guess where stuff are connected by looking at pictures isn't the best.

bitterOz (author)  mandu2210 months ago
I have another idea mandu22.

Remove the existing LiquidCrystal library from Arduino before adding this library. I believe that will solve your problem.
jimpeachey23 days ago

Anyone got any ideas on the ATTiny85 issue please?

bitterOz (author)  jimpeachey22 days ago

Hi Jim,

Let me have a look in this for you over the next day or two.

BitterOz thanks. I'm waiting on some bits to make building the board easier. I'm pretty sure that the ATTiny pins are right and once i get some better connections i'm sure it will be OK. Having an expert check it out for me would be great though. I'm also looking at adding another pot for the backlight. I'll post once i have everything working.

michael_x25 days ago
Re Step2:
Strips are easily and safely cut by enlarging holes with a 4mm drill.
Later steps show there are enough spare holes that can serve as separators.

If you want to enhance your instructable to a foolproof version, you might want to flip the picture and enlarge the "cuts" to isolating holes instead.

BTW: Thanks for this "long term" project ( > 6 sec. ) ;)
bitterOz (author)  michael_x22 days ago

6 seconds after your hour or two of building... yes... never let the truth get in the way of marketing!

Good feedback on the cuts/tracks. In a future revision I will add both versions for users to be aware.

Thanks for the feedback.

p_j_s1 month ago

Just built this - it works...did it on breadboard first, and had real problems with induced noise due to all my long jumper leads picking up random signals. Caused random garbage characters to appear on LCD. Over on the Arduino forums an electronics guru suggested adding 0.1uF caps across Vss/Vdd of the LCD, plus 0.1uF and 47uF across pin 8 & 16 (gnd and Vcc) of the 595. I did that on the breadboard but still had issues.

Now I've soldered everything down onto veroboard as per your instructions, and haven't yet added any of the suggested capacitors, and the induced noise problems seem to have gone away.

One thing I need to point out though, is that your code (sketch) fails to illuminate the backlight. You've responded to others above saying this is achievable by adding EITHER lcd.setLED1Pin(HIGH) OR lcd.setLED2Pin(HIGH) - but for me, ONLY the call to lcd.setLED2Pin(HIGH) illuminates the backlight.

Others seem to be puzzling over this and missing the additional instructions in these comments.

So, just to summarize, you need to add a call to lcd.setLED2Pin(HIGH) just after the call to lcd.begin();

Other than that, it all works great... (although it's impossible to adjust the 10k pot once the LCD is plugged into the header sockets!...minor design flaw :) )

p_j_s p_j_s1 month ago

Oh yes, one other thing - your schematic has pin 8 of 595 unconnected...it should be connected to GND - but this isn't a problem in the veroboard layout.

Thanks for a very useful instructable.

bitterOz (author)  p_j_s22 days ago

Hi and thank-you for your comments and note of success.

Backlight. I am going to make it clearer in a coming update to this guide just how this works to avoid future confusion.

Capacitors. The joy of DC, resistance and noise. Depending on the quality of breadboards, veroboard, power supply et al will change the needs of capacitors. In reality, it is probably best to always add them however my use-case of this LCD board is for testing only, production applications are built on printed PCBs with caps. Thanks for going to the effort of adding the values to help future builders.

10k pot. Yes, it needed to go somewhere and that was the easiest place at the time, I have since swapped mine out with a right-angle pot to make it accessible (not that I have ever adjusted it beyond first-use).

GND on pin 8 of the 595. Yes, my mistake. I will update this shortly to reflect this feedback.

Thanks again. I hope you enjoy your "6-second" hookups (after an hour of building).

jimpeachey26 days ago

OK,i have been having real problems with this, some of it may be connection based but that can be sorted. What i am trying to do is recreate this but use an ATTiny85, as someone else has sort of done. What i did (assuming the connections work) was change the

LiquidCrystal595 lcd(7,8,9); command to

LiquidCrystal595 lcd(0,1,2);

to allow for the ATTiny85 pins.

Could someone tell me whether this should work or not. I added pin 8 of the LCD to ground and also added the

lcd.setLED2Pin(HIGH); although i'm not sure this would stop it working totally. Im a newbie to all this and pretty much rely on you experts so that i can cut and paste as necessary, i wish i could do what you do but i'm afraid i cant. To be honest i thought i had this one and still cant see where i might have gone wrong. One problem is checking that the code actually went to the ATTiny but i guess i have to assume it did as everything points to the fact that it should have.

Please help, anyone; this is for a project that i want to complete pretty soon. Thanks for the initial instructable, without people like you, people like me wouldn't be able to do any of this stuff!

Yours hopefully Jim.

spirit183 months ago
hi i also have a little issue or it depant on how little you think it is..

finaly i have this project up and running, as it took me some hours to get it work..
and the issue i have is , if i use "lcd.begin(16,2);" the contrast is realy low its realy hard the read tekst on the lcd..
but if i use "lcd.begin(16,1);" everythink is fine.. and i can read the tekst perfect..
so it wasnt a Hardware issue but on the software..
spirit18 spirit183 months ago
oke leave it i solved it to ground the Contrast pin better , and to use my 2A 12V supply
now also the lcd.setLED2Pin command works how it should be :-S realy strange..
leadergr5 months ago
how i will turn on or off the backligth of the lcd
bitterOz (author)  leadergr5 months ago
I also document how to turn on and off the backlight in my post to transcendtient dated Jun 2, 2013. 4:30 AM
bitterOz (author)  leadergr5 months ago
Hi leadergr,
The backlight can be turned on and off when you write a new line of text to the display. If you read the commend from user lobonse posted on Nov 5 you will see all the commands you need.
If this does not solve your problem, please come back and ask again.
apapai8 months ago
I've been trying to build this for a day now but could manage to drive my LCD with it. I have a DFRobot LCD KeyPad shield (not just a simple LCD). The best I got was showing random characters. I left the NPN out so the screen is always on. Any idea what's wrong? The standard arduino LCD library works just fine.
bitterOz (author)  apapai5 months ago
Hi Apapai,
Try removing the standard Arduino LCD library and just use the linked download - please let me know if this fixes your problem - it has for others.
lobonse5 months ago
Hello, I finished the protoboard today, the display works with the code supplied, however the backlight doesn't come on. I've cleaned the board and double and triple checked for shorts ( even used a magnifying glass ). Any ideas?
lobonse lobonse5 months ago
Ok, totally got it now! As you've already explained, to turn the backlight on or off you need to use either lcd.setLED1Pin(HIGH); or lcd.setLED2Pin(HIGH); along with an lcd.print(); line, and lcd.print needs to actually print something { lcd.print("HELLO"); }.

Same goes with turning it off...lcd.setLED1Pin(LOW); {OR lcd.setLED2Pin(LOW)} with lcd.print line.

Is that about correct?
bitterOz (author)  lobonse5 months ago
Hi Lobonse,
You are totally correct. The command to turn the screen on and off is only done when new information is written to the display.
Hope you enjoy it.
TheLUXY1 year ago
Can somebody tell me how to turn backlight on or off in Arduino (code)?
bitterOz (author)  TheLUXY1 year ago
Hi TheLUXY,

You can turn off the display by calling:
void noDisplay();

Turning it on again:
void display();

Other functions available for you are:
void clear();
void home();
void noBlink();
void blink();
void noCursor();
void cursor();
void scrollDisplayLeft();
void scrollDisplayRight();
void leftToRight();
void rightToLeft();
void autoscroll();
void noAutoscroll();
void createChar(uint8_t, uint8_t[]);
void setCursor(uint8_t, uint8_t);
lobonse bitterOz5 months ago
Actually, when i do this the backlight remains off, but the text appears and disappears.
leadergr5 months ago
please th code to turn off /on the backligth 16 pin of lcd
leadergr5 months ago
how i will turn on or off the backligth of the lcd
swanster6 months ago
i have try "lcd.clear" and "lcd.print" in the void loop, it not working.
What is the problems ?
thanks.
stp715a9 months ago
The schematic still shows pin 7 Arduino connected to pin 14 of the 595. "There is an ERROR in the last photo (in step 6). Pin 7 of Arduino not connecting to pin 15 of the shift register but pin 14. Took me a day to figure out what went wrong. " Which is correct? 595 Pin 14 or 15 to Arduino pin 7? Also, if the N on the NPN in the breadboard photo is on the front of the transistor (flat side) then C and E are reversed compared to the schematic. Which is correct? Thank you for posting this.
ngourlay9 months ago
Could I suggest a couple of resistors around the backlight might add a bit of polish to the design? Perhaps a 10K resistor between the transistor and shift register, and a 150 ohm between LCD pin 15 and the 5V supply.
billbillt9 months ago
great
transcendtient10 months ago
By the way this doesn't work for me. I had to use a different library found here http://playground.arduino.cc/Main/LiquidCrystal#Information.
My (16x2) LCD would only display one row of black blocks with your code and setup.
bitterOz (author)  transcendtient10 months ago
Possibly remove the existing LiquidCrystal library from Arduino before adding this library. I believe that will solve your problem and you can then use the code as I suggest below for your relays.
transcendtient10 months ago
I want to use this Instructable, but I'm really bent on using the extra 2 pins on the 74HC595 to run a couple relays for heaters for an Aquaponics setup. How do I toggle those two pins on and off?
bitterOz (author)  transcendtient10 months ago
Hi transcendtient,

All the pinouts for the shift register are easily understood if you look at the library code header file (LiquidCrystal595.h). In there you will find controls for all the ShiftReg PINs. In particular you wish to review the LED1 and LED2 PINs (595 pins 5 & 6).

Currently, one of these is used as the MOFSET/NPN to turn the screen on and off - you can reassign this and keep the screen on if you wish. The other is unused, and could be assigned to work with your relay. The code is:
void setLED1Pin(uint8_t pinValue); and/or void setLED2Pin(uint8_t pinValue);
eg setLED2Pin(HIGH);

To send that command over to the shift register, you need to issue an lcd.print(); command.

In summary, there is ONE available PIN if you use the MOFSET/NPN to turn the screen on and off. I you directly wire the screen to always be on, then you have both LED1 and LED2 PINs which you could attach relays.

Enjoy.
R
trenaud111 months ago
Great build! I'm using this with an ATtiny85, works great. I'm building an intervalometer for my Canon DLSR. The only problem is that i've used all the pins on the ATtiny but I still need one to trigger de camera. Is it possible to use the remaining free pin on the 595 for this? To be specific, is there a function to set individual 595 pins with the LiquidCrystal595 library?
bitterOz (author)  trenaud110 months ago
Hi trenaud1,

Could you use PIN 3 from the ATtiny85 as matt.e.jenkins did for his build?
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!