LCD stands for Liquid Crystal Display. It is a technology that exploits the properties of particular crystals, called liquid crystals, capable of changing the polarity of the light that passes through them. In practice, the liquid crystals act as a real filter, allowing the passage of certain light radiation or not depending on the electric field applied to them. Since liquid crystals can quickly pass from a crystalline phase to a liquid phase, they can, therefore, be applied on a flat surface, thus forming a very thin field of view. This is very useful for producing displays suitable for installation in portable objects or components. Here we are using 16×2 LCD display with Arduino.

1. CONCEPTS

Liquid Crystal Display, 16×2 LCD

The 16×2 display is a versatile output interface on the which two-line messages can be displayed from 16 characters. The form is easily managed through the Hitachi HD44780 controller, emulated by Arduino via one specific software present in its libraries.

16x2 LCD display arduino
Figure 1: 16×2 LCD display

Pin Description of 16×2 LCD display Arduino

  • PIN 1 | VSS: Connect to ground.
  • PIN 2 | VCC: Connect it to 5V power supply.
  • PIN 3 | VEE: Used to adjust contrast the contrast of the LCD using a potentiometer.
  • PIN 4 | RS: Register Select pin is used to switch between command mode and data mode registers. In command mode, you can send commands (like move cursor, blink cursor, change position of text etc.) whereas in data mode you can send the data to be displayed on the LCD.

For Command Mode; RS = HIGH

For Data Mode; RS = LOW

  • PIN 5 | RW: Read/Write register decides whether data should be sent to the LCD or read from the LCD. If you do not want to read from LCD, it is convenient to keep this pin constantly LOW and therefore permanently connected it to the ground.

For Read Mode; RS = HIGH

For Write Mode; RS = LOW

  • PIN 6 | EN: To send data from controller to the LCD you have to send a HIGH to LOW pulse on this pin. and to read the data from LCD you have to send LOW to HIGH voltage on this pin. The pulse must be 450ns wide. In Arduino, you don’t have to send these pulses. It will automatically do it using the inbuilt “LiquidCrystal.h” library.
  • PINS 7 to 14 | D0 to D7: These are the data pins used to send data when you connect LCD in parallel mode. There are two ways to send data using these pins; 4-bit mode and 8-bit mode. Preferably we use 4-bit mode as less number of pins are used.
  • PIN 15 | LED(+): Used to turn on the backlight of LCD. Connect it with +5V supply
  • PIN 16 | LED(-): Used to turn on the backlight of LCD. Connect it with the ground.

LiquidCrystal.h Arduino Library

To control LCD using Arduino you can use this inbuilt library just by calling it in the beginning. This library makes your work a lot easy. Just specify the pins described above into its functions and with few lines of code, it will start working.

Syntax: #include<LiquidCrystal.h>

This library has lots of functions which you can use to fully control an LCD connected to the Arduino board.

2. COMPONENTS

3. CONNECTIONS

Figure Interfacing LCD with Arduino
Figure 2: Interfacing LCD with Arduino

4. PROGRAMS

Program 1: Display custom text on 16×2 LCD

/*UNCIA ROBOTICS | www.unciarobotics.com
  PROGRAM:PRINT CUSTOM TEXT ON 16x2 LCD
  This program prints custom text on 16x2 LCD using 4-bit
  mode and rs,en pins.

  The circuit:
  Arduino    LCD   |   Arduino    LCD
  2          RS    |   5          D5
  3          EN    |   6          D6
  4          D4    |   7          D7
*/

#include <LiquidCrystal.h>    //LCD library
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
  lcd.begin(16, 2);           // number of col. and rows
  lcd.print("Uncia Robotics");// Print text on LCD
}
void loop() {}

Program 2: Display blinking text on 16×2 LCD

/*UNCIA ROBOTICS | www.unciarobotics.com
  PROGRAM:BLINKING TEXT ON 16x2 LCD
  This program blinks the printed text on 16x2 LCD using
  4-bit mode and rs,en pins.

  The circuit:
  Arduino    LCD   |   Arduino    LCD
  2          RS    |   5          D5
  3          EN    |   6          D6
  4          D4    |   7          D7
*/

#include <LiquidCrystal.h>    //LCD library
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
  lcd.begin(16, 2);           // number of col. and rows
  lcd.print("Uncia Robotics");// Print text on LCD
}
void loop() {
  lcd.display();                //show text on LCD
  delay(500);                   //wait for some time
  lcd.noDisplay();              //hide text on LCD
  delay(500);                   //wait for some time

Program 2: Scroll text right to left on 16×2 LCD

/*UNCIA ROBOTICS | www.unciarobotics.com
  PROGRAM:SCROLL TEXT ON LCD
  This program scrolls the text using scrollDisplayLeft()
  on 16x2 LCD using 4-bit mode and rs,en pins.

  The circuit:
  Arduino    LCD   |   Arduino    LCD
  2          RS    |   5          D5
  3          EN    |   6          D6
  4          D4    |   7          D7
*/

#include <LiquidCrystal.h>     //include LCD library
String text = "Uncia Robotics - The Digital Realm";//Enter text
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  lcd.begin(16, 2);           // number of col. and rows
  lcd.setCursor(0, 0);        // set cursor position
  lcd.print(text);            // Print text on LCD
}
void loop() {
  int len = text.length();    //get the length of the text
  for (int pos = 0; pos < len; pos++)
  { lcd.scrollDisplayLeft();  //scroll one position left in loop
    delay(200);               //wait for some time
  }
}

5. FUNCTIONS & LIBRARIES USED



6. FAQs

Can we interface LCD display with Arduino without using Libraries?

Yes, LCD can be programmed without using any Library, But for that, you have to read its datasheet and understand it’s working.

Still, having doubts?

Ask your questions on controlling LCD display with Arduino, in the comments section below or Contact Us.

Leave a Reply