Introduction: LCD Display Tutorial
Want your Arduino projects to display status messages or sensor readings? Then these LCD displays might be the perfect fit. They are extremely common and a fast way to add a readable interface to your project.
This tutorial will cover everything you need to know to get up and running with Character LCDs. Not just 16×2(1602) but any character LCDs (for example, 16×4, 16×1, 20×4 etc.) that are based on parallel interface LCD controller chip from Hitachi called the HD44780. Because, the Arduino community has already developed a library to handle HD44780 LCDs; so we’ll have them interfaced in no time.
- 16*2 LCD Display
- 10K Potentiometer
- 100 ohm Resistor
- Jumper Wires
Step 1: Hardware Overview
These LCDs are ideal for displaying text/characters only, hence the name ‘Character LCD’. The display has an LED backlight and can display 32 ASCII characters in two rows with 16 characters on each row.
Each rectangle contains grid of 5×8 pixels If you look closely, you can actually see the little rectangles for each character on the display and the pixels that make up a character. Each of these rectangles is a grid of 5×8 pixels. Although they display only text, they do come in many sizes and colors: for example, 16×1, 16×4, 20×4, with white text on blue background, with black text on green and many more. The good news is that all of these displays are ‘swappable’ – if you build your project with one you can just unplug it and use another size/color LCD of your choice. Your code may have to adjust to the larger size but at least the wiring is the same!
Step 2: 16×2 Character LCD Pinout
Before diving into hookup and example code, let’s first take a look at the LCD Pinout.
GND should be connected to the ground of Arduino. VCC is the power supply for the LCD which we connect the 5 volts pin on the Arduino. Vo (LCD Contrast) controls the contrast and brightness of the LCD. Using a simple voltage divider with a potentiometer, we can make fine adjustments to the contrast. RS (Register Select) pin lets the Arduino tell the LCD whether it is sending commands or the data. Basically this pin is used to differentiate commands from the data. For example, when RS pin is set to LOW, then we are sending commands to the LCD (like set the cursor to a specific location, clear the display, scroll the display to the right and so on). And when RS pin is set on HIGH we are sending data/characters to the LCD. R/W (Read/Write) pin on the LCD is to control whether or not you’re reading data from the LCD or writing data to the LCD. Since we’re just using this LCD as an OUTPUT device, we’re going to tie this pin LOW. This forces it into the WRITE mode. E (Enable) pin is used to enable the display. Meaning, when this pin is set to LOW, the LCD does not care what is happening with R/W, RS, and the data bus lines; when this pin is set to HIGH, the LCD is processing the incoming data. D0-D7 (Data Bus) are the pins that carries the 8 bit data we send to the display. For example, if we want to see the uppercase ‘A’ character on the display we will set these pins to 0100 0001(according to the ASCII table) to the LCD. A-K (Anode & Cathode) pins are used to control the backlight of the LCD.
Step 3: Wiring – Connecting 16×2 Character LCD With Arduino Uno
Before we get to uploading code and sending data to the display, let’s hook the LCD up to the Arduino. The LCD has a lot of pins (16 pins in total) that we’ll show you how to wire up. But, the good news is that not all these pins are necessary for us to connect to the Arduino. We know that there are 8 Data lines that carry raw data to the display. But, HD44780 LCDs are designed in a way that we can talk to the LCD using only 4 data pins(4-bit mode) instead of 8(8-bit mode). This saves us 4 pins!
Now, let’s connect the LCD Display to the Arduino. Four data pins (D4-D7) from the LCD will be connected to Arduino’s digital pins from #4-7. The Enable pin on LCD will be connected to Arduino #2 and the RS pin on LCD will be connected to Arduino #1.
The following diagram shows you how to wire everything. Wiring connections of 16×2 character LCD and Arduino UNO With that, you’re now ready to upload some code and get the display printing.