Introduction
A 16×2 character LCD (Liquid Crystal Display) is a commonly used display module with Arduino boards for displaying text and data. It is an affordable and easy-to-use display module that can display up to 16 characters per line and up to 2 lines of text. The module can be easily interfaced with an Arduino board and can be programmed to display various types of data, including temperature, humidity, and other sensor readings.
In this article, we will explore how to interface a “16×2 character LCD” with an Arduino board and provide examples of how it can be utilized in various projects.
What is 16X2 Character LCD?
16×2 Character LCD is a type of Liquid Crystal Display module that has the ability to display 16 characters in each of its two rows. It is widely used in various electronic systems for displaying data and information. Each character is made up of a 5×8 or 5×10 dot matrix, and the display is controlled by an external microcontroller, such as Arduino.
Hardware Components
To interface a 16X2 Character LCD with Arduino, you’ll need the following hardware components to get started:
Components | Value | Qty |
---|---|---|
Arduino UNO | – | 1 |
USB Cable Type A to B | – | 1 |
DC Power for Arduino | – | 1 |
16X2 Character LCD | – | 1 |
Potentiometer | – | 1 |
Breadboard | – | 1 |
Jumper Wires | – | 1 |
16×2 Character LCD Pinout
Pin No | Pin Name | Pin Description |
---|---|---|
1 | VSS | Signal ground |
2 | VDD | Logic power for LCD |
3 | V0 | Contrast adjustment |
4 | RS | Register select signal |
5 | R/W | Read/write select signal |
6 | E | Operation enable signal |
7 – 14 | D0 – D7 | Data bus lines used for 8-bit mode |
11 – 14 | D4 – D7 | Data bus lines used for 4-bit mode |
15 | A (LED+) | Anode for LCD backlight |
16 | K (LED-) | Cathode for LCD backlight |
16×2 Character LCD Circuit
Make connections according to the circuit diagram given below.
Wiring / Connections
Arduino | 16×2 character LCD |
---|---|
5V | VCC + LED Positive |
GND | GND + LED Negative |
D4 | D11 |
D5 | D12 |
D6 | D13 |
D7 | D14 |
Installing Arduino IDE
First, you need to install Arduino IDE Software from its official website Arduino. Here is a simple step-by-step guide on “How to install Arduino IDE“.
Installing Libraries
Before you start uploading a code, download and unzip the following libraries at /Program Files(x86)/Arduino/Libraries (default), in order to use the sensor with the Arduino board. Here is a simple step-by-step guide on “How to Add Libraries in Arduino IDE“.
Code
Now copy the following code and upload it to Arduino IDE Software.
// Include the library:
#include <LiquidCrystal.h>
// Create an LCD object. Parameters: (RS, E, D4, D5, D6, D7):
LiquidCrystal lcd = LiquidCrystal(2, 3, 4, 5, 6, 7);
void setup() {
// Specify the LCD's number of columns and rows. Change to (20, 4) for a 20x4 LCD:
lcd.begin(16, 2);
}
void loop() {
// Set the cursor on the third column and the first row, counting starts at 0:
lcd.setCursor(2, 0);
// Print the string 'Hello World!':
lcd.print("Hello World!");
// Set the cursor on the third column and the second row:
lcd.setCursor(2, 1);
// Print the string 'LCD tutorial':
lcd.print("LCD tutorial");
}
Code Explanation
This code uses the LiquidCrystal library to control an LCD display with an Arduino board.
The LiquidCrystal object is created with the parameters specifying the pins for RS, E, D4, D5, D6, and D7 connections.
In the setup function, the number of columns and rows are specified for the LCD display using the lcd.begin
function.
In the loop function, the cursor is set to the third column and first row using lcd.setCursor(2, 0)
. The string “Hello World!” is then printed on that position of the LCD display using lcd.print("Hello World!")
.
Then the cursor is set to the third column and second row using lcd.setCursor(2, 1)
. Finally, the string “LCD tutorial” is printed on that position of the LCD display using lcd.print("LCD tutorial")
.
This code is a simple example of how to use the LiquidCrystal library to control an LCD display with an Arduino board.
Applications
Here are some applications for a 16×2 character LCD:
- Displaying sensor data in real-time
- Displaying the time, date, and other relevant information
- Displaying menu options in a user interface
- Displaying error messages or system status information
- Displaying text messages or prompts in a communication system
- Displaying test results or diagnostic information
- Displaying data in a control system
- Displaying messages in a point of sale system
- Displaying data in a fitness or health tracker
- Displaying messages or prompts in an alarm system.
Conclusion
Interfacing a 16×2 character LCD with an Arduino board is a straightforward process that can add a new dimension to your Arduino projects. Whether you are working on a weather station, a home automation system, or any other project that requires displaying data, the 16×2 character LCD can provide an easy and effective solution. With its affordability and ease of use, it has become a popular choice among hobbyists and professionals alike.