Easy Basics: Project 045a LCD 2004

of Acoptex.com in UNO

Basics: Project 045a

Project name: LCD 2004

Tags: LCD2004, LCD 2004 module, Potentiometer, potentiometer

Attachments: sketch, libraryLiquidCrystal

Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you

In this project, you needed these parts :

1.Arduino Uno R3 (you can also use the other version of Arduino)

2.LCD 2004 1pc

3.Arduino IDE ( you can download it from here  )

4.Jumper cables F-M

5.Potentiometer 1pc

6. Breadboard 1 pc


In this project, we will learn how to use an LCD2004 to display characters and strings. 

Understanding the potentiometer

See more information about potentiometer here.

Understanding LCD 2004

The meaning of LCD2004 marking is Liquid Cristal Display 20 characters by 4 rows, each row displays 20 characters.The LCD is available in a 16 pin package. 

As we all know, though LCD and some other displays greatly enrich the man-machine interaction, they share a common weakness. When they are connected to a controller, multiple IOs will be occupied of the controller which has no so many outer ports. Also it restricts other functions of the controller. 

You can read the specification here.

Signals and contacts of LCD 2004 

LCD2004 has parallel ports, that is, it would control several pins at the same time. LCD2004 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 LCD2004 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.

Signals and contacts of potentiometer

See more information here.


Connect K to GND and A to 3.3 V, and then the backlight of the LCD2004 will be turned on. Connect VSS to GND and the LCD2004 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 LCD2004.  Connect E to pin6 and the characters displayed on the LCD2004 are controlled by D4-D7.

 * LCD RS pin to digital pin 4 

* LCD E pin to digital pin 6 

* LCD D4 pin to digital pin 10 

* LCD D5 pin to digital pin 11 

* LCD D6 pin to digital pin 12 

* LCD D7 pin to digital pin 13 

* LCD RW pin to ground (-) 

* LCD K pin to ground (-) 

* LCD A pin to +3.3V 

* LCD D3 pin NOT USED 

* LCD D2 pin NOT USED 

* LCD D1 pin NOT USED 


* LCD VSS pin to ground (-) 

* LCD VDD pin to +5V 

* LCD V0 pin to potentiometer center pin 

* Potentiometer left pin to +5V 

* Potentiometer right pin to ground (-)

Make sure the pins are connected correctly. Otherwise, characters will not be displayed properly.

The following picture shows the needed connections between the LCD 2004 display and the Arduino Uno.

Step by Step instruction

  1. Plug your Adruino Uno board into your PC and select the correct board and com port
  2. Verify and upload the the sketch to your Adruino Uno.
  3. You may need to adjust the potentiometer on breadboard until LCD2004 can display clearly.
  4. You should now see the characters "ACOPTEX" and "hi boys and girls" rolling on the LCD.



#include // include the library code

With the LiquidCrystal.h file included, you can call the functions in this file later. LiquidCrystal is a built-in library in the Arduino IDE. 

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

char array2 []="hi boys and girls         "; //the string to print on the LCD

These are two character type arrays: array1() and array2(). The contents in the quotation marks "xxx" are their elements, including 26 characters in total (spaces counted). array1(0)stands for the first element in the array, which is a space, and array1(2) means the secondelement 8 and so on. So array1(25) is the last element (here it's also a space).

Define the pins of LCD2004:

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

 Define a variable lcd of LiquidCrystal type. Here use lcd to represent LiquidCrystal in the following code.The basic format of the LiquidCrysral() function is: LiquidCrystal (rs, enable, d4, d5, d6, d7).

So this line defines that pin RS is connected to pin 4, the enable pin to pin 6, and d4-d7 to pin 10-13 respectively.

Initialize the LCD:

lcd.begin(20, 4); // set up the LCD’ s number of columns and rows:

begin(col,row) is to set the display of LCD. Here set as 20 x 4.

Set the cursor position of LCD:

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

setCursor(col,row) sets the position of the cursor which is where the characters start to show. Here set it as 20 col, 0 row.
LCD dispays words inside arrays:
for ( int positionCounter1 = 0; positionCounter1 < 20; 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(timedelay); //wait for 350 microseconds
When positionCounter1 =0, which accords with positionCounter1 <20, positionCounter1 adds 1. Move one bit to the left through lcd.scrollDisplayLeft(). Make the LCD display array1[0] by lcd.print(array1[positionCounter1]) and delay for timedelay ms (350 ms). After 20 loops, all the elements in array1[]  have been displayed.
lcd.clear(); //Clears the LCD screen and positions the cursor in the upper-left corner.
Clear the screen with lcd.clear() so it won't influence the display next time.
lcd. setCursor (20, 1); // set the cursor to column 20, line 1 Set the cursor of Col. 20 Line 1 where the characters will start to show.
for (int positionCounter2 = 0, positionCounter2 < 20; 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(timedelay); //wait for 350 microseconds
Similarly, the code is to display the elements in array2[]  on the LCD. Therefore, you will see "ACOPTEX" scroll in the top line of the LCD, move left until it disappears. And then in the bottom line, “hi boys and girls " appears, scrolls to the left until it disappears.


We have learnt how to use an LCD2004 to display characters and strings.


  • See attachments on the begining of this project description.
  • We have used the built-in LiquidCristal library in the Arduino IDE. You can see it installed in your PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. It is also attached on the beginning of this project description.


  • See attachment on the beginning of this project description.

Other projects of Acoptex.com
Easy Merry Xmas to everyone of Acoptex.com, Not selected 24-12-2019

Published at 13-11-2017
Viewed: 859 times