16×2 LCD Display interface with Arduino


In this tutorial we will learn How to interface 16×2 LCD display using arduino. LCD displays available in various sizes 8×1, 16×1, 16×2, 16×4, 20 Char x 4 Lines. These all displays can be interfaced using this tutorial. We are more focusing on 16×2 LCD. It is commonly used.

Interfacing a character LCD to an Arduino adds a nice element of readability to your project. Many of the best Arduino projects around the world sport LCD displays. These LCDs can be used to display information from the Arduino or any sensor connected to it. For example, you can create a temperature monitoring system which displays the temperature on your Arduino. You can make your own speedometer that displays your speed on the LCD! Depending on what you want to build, an LCD is a highly useful output device for your Arduino.

What we are learning in this tutorial?

  1. Pin configuration of LCD.
  2. How to connect LCD with Arduino?
  3. How to move cursor on LCD?
  4. How to make custom characters?

LCD Pinout

All HD44780 (JHD16x2) driver based LCDs have 14 or 16 line interface. Backlight connections are connected to +5V supply through 330 Ohm current limiting resistor. In most cases we don’t read the display so it is better to connect R/W LCD pin to GND. For contrast setting, connect LCD contrast Pin 3 to ground through a 1K Ohm resistor. It gives optimum value of contrast. We don’t need to adjust the contrast every time using variable resistor so it is better to use fixed resistor, saves cost and space on PCB.

16x2 LCD PinOut
16×2 LCD PinOut

The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display. The interface consists of the following pins:

A register select (RS) pin that controls where in the LCD’s memory you’re writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD’s controller looks for instructions on what to do next.

A Read/Write (R/W) pin that selects reading mode or writing mode

An Enable pin that 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.

There’s also a display constrast pin (Vo), power supply pins (+5V and Gnd) and LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on and off the LED backlight, respectively.

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal Library simplifies this for you so you don’t need to know the low-level instructions.

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 example shows how to control a 2×16 LCD in 4-bit mode.

Connecting LCD to Arduino

Before wiring the LCD screen to your Arduino or Genuino board we suggest to solder a pin header strip to the 14 (or 16) pin count connector of the LCD screen, as you can see in the image above.
To wire your LCD screen to your board, connect the following pins:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2

Additionally, wire a 1k resistor in between GND and  LCD screens VO pin (pin3). A 220 ohm resistor is used to power the backlight of the display, usually on pin 15 and 16 of the LCD connector

Connect the LCD as shown in circuit diagram.

LCD Arduino Circuit
LCD Arduino Circuit

Arduino Commands for LCD control

Arduino software comes with “LiquidCrystal” Library. It contains many functions to control the LCD.

Let’s see one by one.

1. First step is to include the library using following command.

#include <LiquidCrystal.h>

 2. Initialize the library with the numbers of the interface pins. This library uses only 6 IO pins and always used in 4-bit mode.

LiquidCrystal lcd(RS,E,D4,D5,D6,D7)

As per our connections command becomes

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 3. Set up the LCD’s number of columns and rows depending upon your LCD it is 16×2, 16×4, 20×4 etc.


Our LCD is 16×2 so command becomes

lcd.begin(16, 2);

4. Clear display


5. Move cursor to home position.


6. Move cursor to LCD position.

This command is very useful when we are displaying any sensor value. We can quickly move the cursor to any position where we want to display text or value.

setCursor(Col, Row)

Row and col starts from zero, for line one first character it is


For line two coursor at first character it is


7. Display text on LCD.

This is most important command using this we actually display text on LCD, it is similar to Serial.print command.

lcd.print(“Hello World..”);

There are many other commands only above commands are most commonly used.
These are the cursor and display control commands. Listed below.
Cursor, noCursor, blink, noBlink, display, noDisplay, autoscroll, noAutoscroll, leftToRight, rightToLeft, scrollDisplayLeft, scrollDisplayRight, createChar

8. Custom character command


Arduino Code for 16×2 LCD interface

The above code displays “Hello World” and “circuits4you.com” on LCD. We have seen how to display text and custom character on LCD, also we have learned how to move cursor on LCD. You can try other commands to display cursor and text scrolling.

Leave a Reply