Tag Archives: 16×2

16×2 LCD interface with Arduino

A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical device that uses the light-modulating properties of liquid crystals. Liquid crystals do not emit light directly, instead using a back-light or reflector to produce images in color or monochrome. LCDs are available to display arbitrary images (as in a general-purpose computer display) or fixed images with low information content, which can be displayed or hidden, such as preset words, digits, and 7-segment displays, as in a digital clock. They use the same basic technology, except that arbitrary images are made up of a large number of small pixels, while other displays have larger elements. In this tutorial, we are using 16×2 character LCD display where 16 is characters per line & there are two lines. It means each 16×2 LCD can represent 32 characters, you can represent more characters by scrolling the text.


LCD-RearIn this LCD each character is displayed in 5×7 pixel matrix. This LCD has two registers, command & data. Like its name, Command register stores command sent to LCD & data register stores the data to be displayed on LCD. Basically the data is ASCII characters which is sent to be displayed on LCD. For more details about LCD, check here.


  • +Vcc: Supply voltage is 4.7V to 5.3V DC
  • GND: Ground (0V)
  • Contrast: Contrast adjustment of LCD, through variable resistor to +Vcc
  • RS: It means ‘Register Select’, Selects command register when low & command register when high
  • RW: It means ‘Read/Write’, Low to write the register and high to read from register
  • EN: It means ‘Enable’, sends data to data pins when a high to low pulse is given.
  • D0 to D7: 8 bit data pins
  • Back-light+ : Vcc (+5V) for LCD back-light
  • Back-light- : Ground (0V) for LCD back-light

Connection with Arduino UNO R3

There are two methods to interface 16×2 LCD with Arduino:

  1. Connect all pins of LCD to Arduino
  2. Use I2C module and connect to Arduino by two pins only

In first method, RS, R/W, EN and Data pins will be connected to Arduino;

As shown in above image, contrast pin is connected with pin 6 of Arduino hence contrast will be adjusted by value set in code. In the program ‘LiquidCrystal’ library so make sure you have same library installed in your Arduino IDE. (You can install libraries from Sketch>Include library>Manage libraries)

Code for direct connection method:

You can download above code from here.

In another method, an I2C module will be connected to LCD. By using I2C module only two pins SDA (Serial Data) & SCL (Serial Clock) will be used from Arduino so less wiring for this. LCD will receive commands from Arduino by I2C protocol

As shown in above image, I2C module is connected to LCD directly (For safer side, solder a female header strip on LCD and connect I2C on that so if somehow I2C module or LCD stops working then it can be easily replaced). You can connect multiple I2C device parallely on same pin. Actually A4 & A5 pins are SDA & SCL so same can be connected on A4 & A5 too(Check Arduino pinout first). There will be a jumper on I2C module which is used to turn on-off LCD backlight. You will find a potentiometer which is actually contrast set for LCD.

Code for I2C connection method:

You can download above code from here.

I2C module & its interface with LCD looks like this:

One more difference between both connection type is library. You need different library for I2C which is ‘LiquidCrystal_I2C’ and it is available here.

Before proceeding for I2C code download, you need to confirm I2C address. Each I2C module has an address which we need to mention in second line LiquidCrystal_I2C  lcd(0x3F, 16, 2); Here i’ve mentioned 0x3F because my I2C module has this address. To know your I2C module address you may need to run I2C scanner program in your Arduino and get I2C address on serial monitor like ths;

I2C scanner

Use this tutorial to know the address of your I2C device. Get I2C address, put in above code & eureka…!!!

After connecting LCD with Arduino you can display sensor & variable values, text messages & also can set values by interfacing keypad with Arduino. Give your feedback about this tutorial in Contact, Your feedback will be appreciated.

Join on FacebookTwitterInstagram & Telegram for latest updates.