16x2 LCD(1602A) Interfacing With Arduino UNO

When it comes to embedded systems, display is an important component either you want the user to have some information or you want your user to better control the system, display is an important part. Display screens comes in different technologies with different dimensions to suit vast needs of embedded systems and the ever growing industry needs, from character display screens to advance graphics rendering screens there is a huge variety.

1602A LCD display with Arduino UNO

In this tutorial we will be looking at interfacing of a 16x2 character display screen with Atmel microcontroller based popular board called Arduino. To be specific we are using 16x2 LCD panel with model no. 1602A (shown in Fig.1) and the board we are using is Arduino UNO(shown in Fig.2).

Fig.1  :   16 X 2 LCD Panel 1602A

Arduino UNO

LCD Pin Configuration


         First thing you need to be familiar with is the pin configuration of LCD panel. The 1602A LCD panel has a total of 16 pins. The following Table shows the pin number with corresponding name and function.
1 VSS The ground pin, this pin must be connected to the common circuit ground
2 VDD The Power Pin this must be connected to the regulated 4.5-5 V regulated supply
3 VO This pin controls the opacity of characters on the LCD screen, connecting it to 5 V will give you block of dots instead of character, on the other side connecting it to the ground will make the opacity of characters 0 and the characters will not visible.
4 RS Register select pin. When RS=0 Command register is selected, when RS=1 Data register is selected
5 RW Read/Write selection bit. When RW=0 LCD registers can be read, when RW=1 LCD registers will be available to receive data.
6 E Enable pin. This pin controls the entire operation of LCD whether it's write operation or read operation.
7 D0 1st bit of Data/Command byte
8 D1 2nd bit of Data/Command byte
9 D2 3rd bit of Data/Command byte
10 D3 4th bit of Data/Command byte
11 D4 5th bit of Data/Command byte
12 D5 6th bit of Data/Command byte
13 D6 7th bit of Data/Command byte
14 D7 8th bit of Data/Command byte
15 A/LED+ The brightness control pin. This pin controls the brightness if the LCD screen, connecting it to the +5v will give the full brightness while connecting to ground will cause the back lite of the LCD to turn off. This is mostly connected to +5 V through a low value resistor (e.g. 330 ohms)
16 K/LED- Must be connected to ground

LCD Interfacing Protocol


Before we move on with the arduino board and LCD 1602A it should be good to have the knowledge of the procedure or more precisely the protocol of the LCD interfacing The arduino UnO board uses the 4bit- interfacing with the LCD out of two interfaces i.e. 8-bit mode and 4-bit mode. Although as along as you are using Arduino UNO with LCD panel you don't need to know about it, anyways if you are interested you can read the following tutorial

Protocol of interfacing a 16x2 LCD to microcontrollers.



Arduino and 1602A LCD Wiring Diagram


LCD Hardware Interfacing with Arduino


Ok so now let's get started to the practical implementation of this circuit. As said before we will be using Arduino UNO, but need not alarmed you can use any other arduino board they all support the LCD interfacing with more or less same connection and the code.

first connect your LCD panel to the arduino board as shown in the following diagram.

So your final circuit should look something like this
Arduino LCD interfacing Circuit diagram

To avoid any mistakes look closely to the circuit and connect your board with the LCD screen carefully.

Arduino Code


Now that we have completed our system physically, it's time to write some code. We will use official arduino ide for developing firmware for the board.
The entire code is actually very short and simple because luckily arduino handles most of the things in the background.


#include <LiquidCrystal.h>
           // initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
          // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
          // Print a message to the LCD.
  lcd.print("I Am Legend!");
}
void loop() {
         // set the cursor to column 0, line 1
         // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
         // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}


The first line of the code is essential, it just includes the builtin in LCD library of arduino. 
In the second line we initialize the library by telling it the pin connections. The first two parameters of the function lcd function are the respective pin numbers of the RS and E pin. If you are thinking about RW pin, it's not connected to the arduino but connected directly to ground.
Now in setup section first we begin lcd operation by using function begin which takes two parameters, columns and rows of the LCD respectively.  In the next line the magic happens we print a string by using function print.
In the loop module of the code we choose the write position on 2nd row and 1st column and print the number of seconds passed since we started the board.
Now compile the code, if everything goes right you should see something on the screen like in the top figure.



Important Notes :


  • RW pin must be connected to ground.
  • VO pin must be connected to a voltage in between 0 - 5v or else none of the characters will be displayed and then you will be finding out "Why my lcd is not working with arduino? "

2 comments:

  1. Online Slots | Situs Judi Slot Online Terpercaya 2021
    Pragmatic septcasino Play merupakan situs judi slot หารายได้เสริม online terpercaya yang menyediakan permainan casino online yang didukung provider resmi seperti casino serta 1xbet korean judi

    ReplyDelete