Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)
Target Amount: $2000
Amount Raised: $359
Top Donor: D.C. $30
Created on: 3 August 2012
In this tutorial you will connect a LCD (Liquid Crystal Display) to the Arduino Uno and then run the Arduino LCD example programs that are built into the Arduino IDE.
It is recommended for beginners to complete all the Arduino tutorials up to and including Tutorial 10: Ten Arduino Projects for Absolute Beginners.
Read about Liquid Crystal Displays (LCD). You will also need to prepare your LCD by soldering wires or a pin header to the display unless your LCD already has connections that allow you to connect it to a breadboard. Read the article on soldering irons and on soldering. The article on soldering has a video that shows how to solder a pin header to a LCD display.
Besides an Arduino Uno board, USB cable, wire links and a breadboard, you will need:
|1||47 ohm resistor (yellow - violet - black)||R1||1/4W, 5% or better
Only needed if using LCD backlight
|1||10k potentiometer||RV1||Trimpot or panel mount. Used for LCD contranst||Potentiometer|
|1||MSC-C162DYLY-4N (Truly) or PC1602LRS-FWA-B (Powertip) or similar||2 line by 16 character LCD, HD44780 compatible
The display can be with or without backlight. The two parts mentioned here both have backlights.
|1||16 way single in-line pin header||Single in-line pin header, 16 pins (2.54mm pin spacing) to be soldered into LCD for connection to breadboard||Header|
Before wiring up your LCD to the Arduino, make sure that your LCD has the same pin numbering as the one in the circuit diagram below. If it does not, you will need to make sure that you make the correct connections between the LCD and Arduino. Also refer to the Arduino Liquid Crystal page for connections to a different LCD that has pins at the top of the LCD instead of at the bottom. The pin numbering on the physical LCD used in this tutorial can be found on the LCD page. When building the circuit, you will need to refer to the diagram or photo showing the physical pin numbering / pin names of the LCD to make sure that you are connecting the LCD correctly.
The circuit diagram shows that the following connections are made:
|Pin 11||→||E (Enable)|
The following are all connected to the Arduino GND:
The centre pin (or wiper) of the potentiometer is connected to the LCD V0 pin.
The following are connected to the Arduino 5V pin:
The first four data pins of the LCD (DB0 to DB3) are left disconnected as the LCD will be run in 4-bit mode where these pins are not needed.
The 47 ohm resistor provides current limiting for the LCD backlight and will not be needed if your LCD does not have a backlight.
The 10k potentiometer adjusts the LCD contrast. After powering up the circuit, you will need to adjust the contrast pot. until you can see the dots of the display or characters being displayed if a program (sketch) has been loaded to the Arduino and has written to the LCD.
After preparing your LCD display by soldering a pin header to it, get ready to plug it into the breadboard. Also be sure to check the datasheet for your LCD to see what the pin names are so that you can connect it correctly. Be very careful not to connect the LCD power pins the wrong way around as this will most likely destroy the LCD.
Insert the LCD into the top holes of the top vertical breadboard connecting strips. Do not insert it into either of the top horizontal rails. Get four wire links ready for connecting to the LCD data lines.
Connect DB7 of the LCD to pin 2 of the Arduino, DB6 to pin 3 of the Arduino, DB5 to pin 4 of the Arduino and DB4 to pin 5 of the Arduino.
Connect the LCD E pin to pin 11 of the Arduino and the LCD RS pin to pin 12 of the Arduino.
Connect the R/W pin of the LCD to the bottom rail of the breadboard. Connect the Arduino GND to the bottom rail of the breadboard.
Connect the 10k potentiometer so that the centre pin connects to the LCD V0 pin. If using a trimpot, make sure that it is placed across the centre breadboard channel.
Connect the VDD pin of the LCD to one of the potentiometer outer legs. Connect this same leg to the Arduino 5V pin.
Connect the other outer leg of the potentiometer to the bottom GND rail of the breadboard. Connect the LCD VSS pin to GND. Connect the LCD backlight cathode BLC pin to GND if present on your LCD.
Connect the LCD backlight anode (BLA) through a 47 ohm resistor to 5V.
After connecting the LCD to the Arduino and checking the connections carefully, connect the Arduino to the PC via a USB cable. If your LCD has a backlight, this should light up. Adjust the contrast potentiometer until you can see the dots that make up the characters of the display. You can make finer adjustments to the contrast after something has been written to the display.
To test the LCD, load the HelloWorld program to the Arduino from the Arduino IDE. It can be found in the Arduino IDE at: File → Examples → LiquidCrystal → HelloWorld. Find the details on the Arduino LiquidCrystal page.
This program displays the text "hello, world!" on the top line of the LCD and then displays an incrementing number on the bottom line of the LCD as shown in the video below. If you do not see the text, try turning the potentiometer to one extreme or the other until you can see the text. If it is still not visible, unplug the USB cable and check your connections again.
Can't see the video? View on YouTube →
If the HelloWorld program worked on your Arduino LCD interface, then the other LCD example programs will also work. They are listed below. Each of these programs can be found under File → Examples → LiquidCrystal.
Arduino website page: LiquidCrystalAutoscroll
Demonstrates scrolling of text to the left on the LCD.
Arduino website page: LiquidCrystalBlink
Demonstrates blinking of the LCD block cursor.
Arduino website page: LiquidCrystalCursor
Demonstrates blinking of the LCD cursor.
Arduino website page: none
This program would not verify (compile) in Arduino IDE 1.0. The IDE error message points to this line of code:
Comment this line out like so (add two forward slashes and a space in front of the line of code):
Click the Verify button again and then upload the program.
This program demonstrates drawing custom characters. A smiley face and stick man are displayed. By commenting out the line of code, the heart that is supposed to be displayed after "I" is missing.
Arduino website page: LiquidCrystalDisplay
Flashes text on and off.
Arduino website page: LiquidCrystalScroll
Demonstrates scrolling text left and right.
Arduino website page: none
Displays text sent from the Arduino Serial Monitor window on the top line of the LCD. After loading this program, open the Serial Monitor window and send some text to the LCD. See the Using the Arduino Serial Port tutorial for instructions on how to use the Arduino Serial Monitor window.
Arduino website page: LiquidCrystalSetCursor
Writes to every character position of the LCD. Fills the entire screen with a single lower case letter starting from 'a' through to 'z'. Starts with 'a' again after writing 'z'.
Arduino website page: LiquidCrystalTextDirection
Demonstrates moving the cursor left and right.