Interfacing LCD with Arduino

How to interface LCD(Liquid Crystal Display) with Arduino and display message

Interfacing LCD with Arduino

Interfacing LCD with Arduino is easy. Here we show how to interface LCD(Liquid Crystal Display) with Arduino and display message. The LCD(Liquid Crystal Display) will be connected to Arduino and using Arduino programmer desired message to be displayed on the LCD. To do this the Arduino LiquidCrystal library will be used. This works with any LCD has the Hitachi HD44780 driver on it.

To display any message on the display, first the interface between the LCD and its controller has to be made to the Arduino. The LCD usually has 16 pins or 14 pins. They are the same and both will work. The only difference is the backlight connection. In LCD with 16 pins there are 2 extra pins for backlight connection whereas in 14 pin LCDs these are not present. These are unessential for working of the LCD and are optional. That is you can just leave these backlight pins unconnected. We will be using 16 pins but these two pins will not be used.

LCD(Liquid Crystal Display)

Following is an example of LCD. This is JHD162a LCD which has 16×2 dimension.

The pin count starts from right to left. And so you can see the leftmost pins are not connected. The rightmost pin is the power supply pin Vcc and should be connected to the 5V output pin of arduino. The 2nd pin is the ground and should be connected to the arduino ground. The 3rd pin is for contrast control and is named VEE. The 4th pin is the RS(Register Select) pin which is used to select either the command register or the character register inside the LCD controller. The 5th pin is the R/W(Read/Write) pin. For reading from LCD a 1 or HIGH is transmitted and for writing to LCD a 0 or LOW is transmitted. So for only displaying message on the LCD we make this pin LOW by connecting it to ground. The 6th pin is the E(Enable) pin which is used to tell the LCD controller that message is being transmitting for display.

Circuit Diagram for Interfacing LCD with Arduino

Following shows the circuit diagram of how LCD should be interfaced with Arduino.

Interfacing LCD with Arduino

The LCD pins and their functions was explained above. The following table shows which Aruino pin is connected to the LCD pin.

Arduino Pins to LCD pins

Arduino PinLCD pin

As you might have noticed we used only 4 data lines. This is because we can choose either to use all 8 data lines(D7 downto D0) or just 4 data lines. In this example we have used the D4, D5, D6 and D7 data lines. Also notice that the VEE pin of LCD is connected to the center pin of 10KOhm potentiometer and that the RW(Read Write) pin is grounded as we just want to display a message.

Programming LCD with Arduino

In contrast to programming raw microcontroller to work with LCD, programming LCD to work with Arduino is easy. With few lines of codes you can display message on the LCD. This is due to fact that LCD programming is done with Arduino using the LiquidCrystal library. This library has preset commands which you can use to ease the work. You just need to use the initialize commands(or functions) and print function to display your message.

To tell the Arduino compiler that you will be using this library you have to specify the library at the top of your program.

Next you specify the Arduino pins to be used. In this example(see above circuit diagram), we have used the Arduino pins 2, 3, 4, 5, 6 and 7 and LCD pins 1, 2, 3, 4, 5, 6, 11, 12, 13 and 14. So we have to tell the Arduino compiler which Arduino are being used. This is done by the following statement.

Now we have to specify the dimension of the LCD, that is the number of column and row which in our case is 16 column and 2 rows. This setup is done within the setup() function as follows.

Thats it.

All that is left to do is to send the message to be displayed. This is done using the print statement and this statement goes also into the setup() function.

The following is the full program code.

So in this way you can interface LCD with Arduino UNO board and display desired message on the LCD.

See also our other Arduino tutorials- IR Infrared Obstacle Avoidance Sensor Module with Arduino and Real-Time data acquisition from Arduino to Matlab.

If you like this tutorial share it and don’t forget to subscribe.

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%

Leave a Reply

Your email address will not be published. Required fields are marked *

PCB Toner transfer using nail polish remover without heat

PCB Toner transfer using nail polish remover without heat

How to program Arduino using ATMEL Studio 7

How to program Arduino using ATMEL Studio 7