Introduction: How to Use an LCD Display - Arduino Tutorial

The LiquidCrystal library allows you to control LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually find them by the 16-pin interface.

In this tutorial you will learn how to use LCD 16x2 display (and 20x4) with Arduino uno.

You will also learn how to use lcd.begin(), lcd.print() and lcd.setCursor() functions

So, let's get started!

Step 1: What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard
  • LCD 16x2
  • Potentiometer (e.g. 4.7K)

Step 2: About the LCD Dislpay Pinout

The parallel interface consists of the following pins:

  • Power Supply pins (Vss/Vcc): Power the LCD
  • Contrast pin (Vo): Control the display contrast
  • Register Select (RS) pin: Controls where in the LCD's memory you're writing data to
  • Read/Write (R/W): Selects reading mode or writing mode
  • Enable pin: Enables writing to the registers
  • 8 data pins (D0 -D7): The states of these pins (high or low) are the bits that you're writing to a register when you write, or the values you're reading when you read.
  • Backlight (Bklt+ and BKlt-) pins: Turn on/off the LED backlight

The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I/O pins from the Arduino, while the 8-bit mode requires 11 pins.

For displaying text on the screen, you can do most everything in 4-bit mode, so in this tutorial we will use 4-bit mode.

Step 3: The Circuit

The connections are easy, see the image above with the breadboard circuit schematic.

Step 4: The Code

Here's the code, embedded using codebender!

The lcd.begin(16,2) command set up the LCD number of columns and rows. For example, if you have an LCD with 20 columns and 4 rows (20x4) you will have to change this to lcd.begin(20x4).

The lcd.print("--message--") command print a message to first column and row of lcd display. The "message" must have maximum length equal to lcd columns number. For example, for 16 columns display max length is equal with 16 and for 20 columns display max length is equal with 20.

The lcd.setCursor(0,1) command will set cursor to first column of second row. If you have an LCD 20x4 and you want to print a message to column five and third row you have to use: lcd.setCursor(4,2).

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board!

You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code. For example, try to change message on first and second row.

Step 5: Well Done!

You have successfully completed one more Arduino "How to" tutorial and you learned how to use an LCD display with Arduino uno.

I hope you liked this, let me know in the comments.

There will be more of them, so make sure to click Follow button!

Comments

author
yash0011 made it!(author)2017-03-21

it was great fun i did it

author
yash0011 made it!(author)2017-03-19

what if i do not have the potentiometer

author
TimC211 made it!(author)2017-01-26

I made it, but the LCD didn't work?!?

author
TimC211 made it!(author)2017-01-26

YOU NEED TO HELP ME

author
TimC211 made it!(author)2017-01-26

Although I DID use an Arduino MEGA

author
cheesepones+ made it!(author)2017-01-26

my first arduino project

temp_1902868002.jpg
author
woutermoors made it!(author)2016-10-25

do you need to use 3 PMW pin's

author
woutermoors made it!(author)2016-10-25

what kinds of potentiometers can be used? Because i'm not able to find the one used in the tutorial

author
RafayJ made it!(author)2015-07-22

NiCee instructables

author
ritihnhaaaa made it!(author)2016-08-23

I agree w/ u!!!11!!
p.s. nice pic! ;) :*

author
norand made it!(author)2016-01-07

:D

IMG_6222[1].JPG
author
ritihnhaaaa made it!(author)2016-08-23

Really good!! Great picture!!
#naoseisetafocando

author
pchaure made it!(author)2016-02-22

can i use a b50k potentiometer? ☺

author
ritihnhaaaa made it!(author)2016-08-23

Yes, you can! #naopassarao

author
MauroR2 made it!(author)2016-05-29

Funcionou! Obrigado, ajudou bastante.

It Works, tanks, helps a lot.

20160529_111816.jpg
author
ritihnhaaaa made it!(author)2016-08-23

BRASIL aqui tmb!!111

author
ritihnhaaaa made it!(author)2016-08-23

Thank youuu!!!!1!!11!!
It helped me a LOT!!!!!!!!!!!!!111
My phone number is 55+368629865
I'm gonna leave u a selfie i made last night. I look a little bit old but I'm just 20yo.
XOXO

raimunderas.jpg
author
pedrero77 made it!(author)2016-08-06

I had some issues with the instructions. It took me a while to figure out that the two instructions: void setup and void loop were both trying to right onto the display.

once you comment one of them out, then it works beautifully.

One more thing I'd like to add is that the BL+and BL-(two last pins in the lcd display) don't need to be connected. In fact I think it would be better to use the potentiometer to control the background light.

FullSizeRender.jpgFullSizeRender (1).jpg
author
Jens2301 made it!(author)2016-06-04

Thank you so much, it works perfect :)

author
Jens2301 made it!(author)2016-05-16

Mine won't work anyone that can help?

author
MarkM17 made it!(author)2016-04-30

Great work, also works on the Nano no probs. Did not use the plugin thou.Thank you

author
Gunterman5 made it!(author)2016-04-15

How would you be able to add input?

author
anthonyHKS made it!(author)2015-11-12

Hi im new at this i have built my board just as instructed but i cant get any text to appear on the screen any suggestions as to what is wrong ?

author
JamesO76 made it!(author)2016-04-02

Try adding

lcd.setCursor(0, 0);

before writing to screen

author
JamesW230 made it!(author)2016-03-29

I don't understand the purpose of the potentiometer. Why can't a resistor be used instead?

author
derhel made it!(author)2016-03-30

Hi JamesW230

The Potentiometer is usually used to adjusting the contrast of the LCD display. So yes you can use a resistor if you know the best resistor value for your needs

author
KennethG9 made it!(author)2015-10-26

This overdrives the backlight doesn't it? I added a 200Ohm resistor to mine between the LED pin and 5V+ to bring it under 20ma. Other than that great tut and thank you very much.

author
Batool_Khader made it!(author)2015-09-27

I made the connections but I have a problem that when I connect VCC to 5V the arduino boards disconnects. What is the reason for that and how to fix it ?

author
3ddiePower made it!(author)2015-09-11

used this instructable and the Crystal library reference text to run some great tests on my LCD, even though it appears i've used all pins on the LCD I only connected jumper wires to the ones mentioned above. Worked great i just added the backlight as i couldn't read my LCD without it but after that it was great. thanks for the post.

IMG_3072.jpgIMG_3074.jpgIMG_3075.jpg
author
Restu21 made it!(author)2015-09-10

can i connect it to database?

i'm sorry, newbie

author
rene14 made it!(author)2015-07-17

Do I need a potentiometer?

author
codebender_cc made it!(author)2015-08-15

Hello, yes you will need one 10K pot. Why? Because with this you can adjust the contrast of yours display.

author
ToreE made it!(author)2015-08-06

No rene14, I never use a potentiometer to an LCD display.

About This Instructable

108,880views

330favorites

License:

Bio: Arduino Tutorials by Codebender.cc Team
More by codebender_cc:How to use a magnetic door switch / sensor with ArduinoHow to Measure LUX With ArduinoHow to Control an RGB LED Strip - Arduino Tutorial
Add instructable to: