16×2 LCD Interface With Arduino

Today I am going to tell you how to interface 16×2 LCD with Arduino.

Circuit Diagram

LCD

Display has very importance in embedded systems. It is used to interact humans with system. Instructions and device function results are shown on displays. Without display we cannot see what operation is being performed inside the arduino/microcontroller. LCDs are most widely used in embedded systems to provide user interface. In this example I am using HD44780 based 16×2 LCD. This LCD can be interfaced using 8 bit or 4 bit mode. In 8 bit mode all 8 data pins are used while in 4 bit mode only 4 pins of LCD are used. In this project I have used 4 bit mode of operation. 16×2 means it has 16 columns and 2 rows. HD44780 controller is installed on other sizes of LCDs like 16×1, 16×4, 20×2, 20×4 etc.

LCD.jpg
Click to Enlarge

Pin-Out

Pin Symbol Function
1 Vss ground (0 V)
2 Vdd power (4.5 – 5.5 V)
3 Vo contrast adjustment
4 RS H/L register select signal
5 R/W H/L read/write signal
6 E H/L enable signal
7-14 DB0 – DB7 H/L data bus for 4- or 8-bit mode
15 A (LED+) backlight anode
16 K (LED-) backlight cathode

We can read & write data to LCD but to keep things simple we have hardwired R/W line to ground for only writing. It means we can only print on LCD but cannot read back content written in LCD RAM.

Software

In arduino we use builtin library for LCD interfacing “LiquidCrystal.h”. And this makes LCD interfacing with arduino simple and easy.

#include <LiquidCrystal.h>

// Define object of LiquidCrystal class.
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);

  // Print welcome message
  // to LCD.
  lcd.print("Welcome!");
  
  // Set cursor to next line and 
  // first column.
  lcd.setCursor(0,1);
  
  lcd.print("micro-digital.net");

}

void loop() {
  // put your main code here, to run repeatedly:

}