2 Ways Of Interfacing LCD Module With Arduino

Introduction

In this getting started with LCD module tutorial we are going to learn about two different ways of interfacing an LCD module with popular development boards like Arduino Nano, Arduino Uno, Arduino Mega, Arduino Leonardo.

Hardware Used

  • LCD module 16 x 2
  • Arduino UNO
  • Arduino Nano
  • Arduino Leonardo
  • Arduino Mega
ComponentsDIY UsthaddiyusthadAmazon.comamazonBanggoodbanggoodAliExpressali express
LCD 1602 module cart iconcart iconcart iconcart icon
Arduino UNO cart iconcart iconcart iconcart icon
Arduino Nano cart iconcart iconcart iconcart icon
Arduino Leonardo cart iconcart iconcart iconcart icon
Arduino Mega cart iconcart iconcart iconcart icon
LCD to IIC(I2c) modulecart iconcart iconcart icon

Software Used 

  • Arduino IDE

Libraries Used

  • LiquidCrystal Library – Will available in Arduino IDE by default – For the first method
  • LiquidCrystal I2C Library – Download  – For the second method
  • Wire Library – Will available in Arduino IDE by default

A little bit about LCD modules…

LCD modules are coming in different colors and sizes with a different number of displayable characters. the most commonly used one is LCD1602 which can display 16 characters in each line, which is a total of 32 characters. Some other sizes are,

  • LCD1604 – 16 char / 4 line
  • LCD2004 – 20 char / 4 line
  • LCD1602 – 16 char / 2 line
  • LCD1601 – 16 char / 1 line etc…

PIN Description:

Pin NumberNameDescription
1VSS (0v)Ground Potential
2VDD (5v)Positive Voltage
3V0 (Contrast)Contrast adjustment; 0v: Max contrast; 5v: Min contrast
4RSRegister Select; 0: Instruction Register 1: Data Register
5RWRead Write Select pin 0: Write mode; 1: Read mode;
6EEnable Pin To enable the LCD Module
7D0-D7LCD Data Bus line. They are responsible for the parallel data transfer.
15LED+ (A)Back Light Source LED Anode
16LCD- (K)Back Light Source LED Cathode

First Method

In the first method, we are interfacing the LCD1602 with Arduino using the data pins of the LCD module. The same code and circuit will work for all Arduino and compatible boards.   Connect the circuit as shown in the below diagram.  

Circuit

#ArduinoLCD1602
1GNDVSS,V0,RW,K
25VVDD
312RS
411E
55D4
64D5
73D6
82D7
93.3VA
  1. First, connect the ground of Arduino to the VSS of the LCD.
    • Then connect the V0 of the LCD to the ground for full contrast
    • Then connect RW to the ground for selecting write mode
    • Then connect K, which is the ground of backlight LED also to the ground.
  2. Then connect the 5V of Arduino to the VDD of the LCD module.
  3. Then connect the digital pin 12 of Arduino to the RS of LCD module.
  4. Then connect the digital pin 11 of Arduino to the E  of LCD module.
  5. Then connect the digital pin 5 of Arduino to the D4 of LCD module.
  6. Then connect the digital pin 4 of Arduino to the D5 of LCD module.
  7. Then connect the digital pin 3 of Arduino to the D6 of LCD module.
  8. Then connect the digital pin 2 of Arduino to the D7 of LCD module.
  9. And finally, connect the 3.3V of Arduino to the A of LCD which is the anode of backlight LED.

Code


//www.diyusthad.com
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  lcd.begin(16, 2);
  lcd.print("First line");
  lcd.setCursor(0,1);
  lcd.print("Second line");
}

void loop() {
}

Video

Second Method

In the second method, we are using a module that converts the 16 pins of the LCD module to just 4 pins I2C communication interface (including power & ground). Connect the circut as shown in the below diagram.

Circuit

List of I2C ports in common dev boards

Code


//www.diyusthad.com
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                   
  lcd.backlight();
  lcd.setCursor(5,0);
  lcd.print("Arduino");
  lcd.setCursor(6,1);
  lcd.print("Nano");
}

void loop()
{
}

Video

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top