LCD Interfacing with Arduino UNO Tutorial

Interfacing 16×2 LCD (liquid crystal display) with the arduino uno. A display device plays a very important role while interacting with any embedded system or digital system. It provides a good interaction between system and the person using it.
It can display numbers, text and any custom character. It has two rows each of 16 columns wide.

We are using Arduino Liquid Crystal Displays library which is based on Hitachi HD44780 and compatible chipset. We can use this library in 4 or 8-bit data mode including the rs, enable and optionally rw control signal.

LiquidCrystal()

Let’s understand the LCD functions and its connections. As LCD can be controlled from 4 or 8-bit data lines. If we are not using the pin D0 to D3 and RW. The lcd even possible to drive. We can use any combination of connection from arduino uno to 16×2 LCD.

LiquidCrystal() function and I/O required
# Function I/O
1 LiquidCrystal(rs, enable, d4, d5, d6, d7); 6
2 LiquidCrystal(rs, rw, enable, d4, d5, d6, d7); 7
3 LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7); 10
4 LiquidCrystal(rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7); 11

From the above table you can use any function to drive the LCD but we are using the first function because it uses only 6-I/O pins.

Hardware Required

  • Arduino Uno
  • LCD Screen (compatible with Hitachi HD44780 driver)
  • 10k ohm potentiometer
  • Breadboard

16×2 LCD Pinout

Pin No. Symbol Description
1 VSS Power Supply GND
2 VDD Power Supply +5V
3 VEE Contrast Adjust
4 RS Register Select Signal
5 RW Data Read/Write
6 E Enable Signal
7 DB0 Data Bus 0
8 DB1 Data Bus 1
9 DB2 Data Bus 2
10 DB3 Data Bus 3
11 DB4 Data Bus 4
12 DB5 Data Bus 5
13 DB6 Data Bus 6
14 DB7 Data Bus 7
15 A Power Supply LCD Back Light VDD (+5V)
16 K Power Supply LCD Back Light VSS (GND)

LCD Arduino Connection

We are connecting the buzzer to the Vcc and collector of the transistor BC548. Here transistor works as a switch and by applying a high signal to its base triggers the buzzer to beep.

16×2 LCD Arduino Circuit

LCD Arduino Coding

LiquidCrystal()
The display can be controlled using 4 or 8 data lines. If we are using function LiquidCrystal(rs, enable, d4, d5, d6, d7) then we need only 6 arduino pins. And leave D0 to D3 pin unconnected. The RW pin tied to ground instead of connected to a pin on the Arduino. Now d0, d1, d2, and d3 are optional; if omitted, the LCD will be controlled using only the four data lines (d4, d5, d6, d7)and RS, E control line.

lcd.begin()
Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display. lcd.begin() needs to be called before any other LCD library commands. lcd.begin(cols, rows) cols: the number of columns in LCD rows: the number of rows in LCD

lcd.print()
Prints text to the LCD.
lcd.print(data)

/*####### LCD Connection with Arduino #######
    RS => digital pin 8
    RW => GND
    E  => digital pin 9 
    D0-D3 => NC(Not Connected) 
    D4 => digital pin 10 
    D5 => digital pin 11
    D6 => digital pin 12 
    D7 => digital pin 13 */ 
// include the LCD library 
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup() 
{   
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  lcd.print("Hello!");
}
void loop()
{
  
}