LCD 1602 With Arduino Uno R3

About: PrimeRobotics is a E-Commerce site, which focus on supplying right products to Electronics Hobbyists, Enthusiast & Students.

In this lesson, we will learn
how to use an LCD1602 to display characters and strings. LCD1602, or 1602 character-type liquid crystal display, is a kind of dot matrix module to show letters, numbers, and characters and so on. It's composed of 5x7 or 5x11 dot matrix positions; each position can display one character. There's a dot pitch between two characters and a space between lines, thus separating characters and lines. The number 1602 means on the display, 2 rows can be showed and 16 characters in each. Now let's check more details!

Step 1: Components:

- Arduino Uno board * 1

- USB cable * 1

- LCD1602 *1

- Potentiometer (50kΩ)* 1

- Breadboard * 1

- Jumper wires

Step 2: Principle

Generally, LCD1602 has parallel ports, that is, it

would control several pins at the same time. LCD1602 can be categorized into eight-port and four-port connections. If the eight-port connection is used, then all the digital ports of the Arduino Uno board are almost completely occupied. If you want to connect more sensors, there will be no ports available. Therefore, the four-port connection is used here for better application.

Pins of LCD1602 and their functions

VSS: connected to ground

VDD: connected to a +5V power supply

VO: to adjust the contrast

RS: A register select pin that controls where in the LCD’s memory you are writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD’s controller looks for instructions on what to do next.

R/W: A Read/Write pin to select between reading and writing mode

E: An enabling pin that reads the information when High level (1) is received. The instructions are run when the signal changes from High level to Low level.

D0-D7: to read and write data

A and K: Pins that control the LCD backlight. Connect K to GND and A to 3.3v. Open the backlight and you will see clear characters in a comparatively dark environment.

Step 3: The Schematic Diagram

Step 4: ​Procedures

Connect K to GND and A to 3.3 V, and then the backlight of the LCD1602 will be turned on. Connect VSS to GND and the LCD1602 to the power source. Connect VO to the middle pin of the potentiometer – with it you can adjust the contrast of the screen display. Connect RS to D4 and R/W pin to GND, which means then you can write characters to the LCD1602. Connect E to pin6 and the characters displayed on the LCD1602 are controlled by D4-D7. For programming, it is optimized by calling function libraries.

Step 1:

Build the circuit.

Step 2:

Download the code from https://github.com/primerobotics/Arduino

Step 3:

Upload the sketch to the Arduino Uno board

Click the Upload icon to upload the code to the control board.

If "Done uploading" appears at
the bottom of the window, it means the sketch has been successfully uploaded.

Note: you may need to adjust the potentiometer on the LCD1602 until it can display clearly.

Step 5: Code

//LCD1602

//You should now see your LCD1602 display the flowing characters "PRIMEROBOTICS" and "hello, world"

//Email:info@primerobotics.in

//Website:www.primerobotics.in

#include

// include the library code

/**********************************************************/

char array1[]=" PrimeRobotics "; //the string to print on the LCD

char array2[]="hello, world! "; //the string to print on the LCD

int tim = 250; //the value of delay time

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(4, 6, 10, 11, 12, 13);

/*********************************************************/

void setup()

{

lcd.begin(16, 2); // set up the LCD's number of columns and rows:

}

/*********************************************************/

void loop()

{

lcd.setCursor(15,0); // set the cursor to column 15, line 0

for ( int positionCounter1 = 0; positionCounter1 < 26; positionCounter1++)

{

lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.

lcd.print(array1[positionCounter1]); // Print a message to the LCD.

delay(tim); //wait for 250 microseconds

}

lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.

lcd.setCursor(15,1); // set the cursor to column 15, line 1

for (int positionCounter2 = 0; positionCounter2 < 26; positionCounter2++)

{

lcd.scrollDisplayLeft(); //Scrolls the contents of the display one space to the left.

lcd.print(array2[positionCounter2]); // Print a message to the LCD.

delay(tim); //wait for 250 microseconds

}

lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.

}

/**********************************************************/

Step 6: Code Analysis

Share

    Recommendations

    • Pie Contest

      Pie Contest
    • Epilog X Contest

      Epilog X Contest
    • Build a Tool Contest

      Build a Tool Contest

    Discussions