Discover 8051 microcontroller with LCD interface 

8051 microcontroller

A decade ago, operations and control processes were performed using only a microprocessor. But nowadays the situation is changing and it is occupied by a new device called a microcontroller. We cannot find any electronic instrument without the use of a microcontroller because the development is very radical. Microcontroller has changed the design of the embedded system in a simple and sophisticated way.

LCD screens use two plates of polarizing materials with a liquid crystal solution placed between them. When an electric current passes through the crystal solution, the crystals are aligned so that no light passes through them. Thus, each crystal is like a shutter, either to allow light to pass through or to block it. There are two types of LCD such as color and monochrome. For projects we use monochrome, while for TVs and laptops we use color. A color LCD screen uses two basic methods of color production. This article discusses the LCD interface with 8051 microcontrollers.

What is a microcontroller?

A microcontroller is a small computer in an integrated circuit that contains memory, programmable inputs, output peripherals, and a processor core. The microcontroller is primarily designed for embedded applications while the microprocessor is designed for personal computers or general purpose applications. Microcontroller instructions are addressable as well as byte addressable. It contains instruction sets that control the inputs and outputs.

8051 microcontroller

LCD Interface Module Review



The 16 x 2 LCD module is a very common type of LCD module that is used in 8051-based embedded projects. It has 16 rows and two [5 x 7] or [5 x 8] LCD dot matrixes. The unit we will be using is the JHD162A number. Available in 16-pin packages with features such as contrast and backlight adjustment functionality and an all 5 x 8 dot matrix dot matrix.

The PINs, their name and functions are shown in the table below

16 x 2 LCD PIN, NAME AND FUNCTIONS

VEE pin 3 adjusts the contrast of the LCD by changing the voltage at this pin. It is made by connecting one end to ground potential and the other to VCC (5V).

R/W pin 5 selects between read and write modes. LOGIC HIGH at the pin makes it easier to read and low on this pin makes it easier to write.

JHD162A has 2 built in registers. Logic High (1) in RS pin 4 identifies the data log. It inserts data on the data line, and the module will recognize it as a command. Low (0) logic in the RS pin will determine the command logging.

Data record - put the data to display

Order history - places orders. It inserts data into an 8-bit data line (DB0 to DB7), the LCD module recognizes it as data to be displayed

E pin 6 turns on the unit. Going from high to low on this pin will turn the unit on.

DB0 to DB7 are data pins. The data to be displayed and the command instructions are placed on these pins.

The LED (+) is the backlight, the anode of the LED and this pin must be connected to Vcc by series current limiting resistance of appropriate value. LED (-) is the backlight and cathode of the LED and this pin must be connected to ground.

16 x 2 LCD module commands

The 16 x 2 LCD module contains a set of preset command instructions. Each command will make the unit do a specific task. The commonly used function and its commands are given in the table below.

16 x 2 LCD Command and Function Module

LCD screen setting

To configure the LCD, here are the steps below and these steps are the same for almost all applications.

Send 38H to 8-bit data line for initialization

Send 0FH to turn on the LCD, turn on the indicator, turn on the indicator flashes

Send 06H to increase the position of the cursor

Send 01H to clear the screen and return the cursor

Sending data to the LCD screen

Below are the steps for sending data to the LCD module. The Boolean state of these pins that causes the module to determine whether a particular data entry is data or a command to display.

Make R/W Low

Set RS = 1, if the data byte is data to be shown and made

RS = 0, if the data byte is a command.

Put data bytes into the data log

Then pulse E from high to low

Repeat the above steps to send other data

LCD connection circuit diagram for 8051 microcontroller

The wiring diagram of the 16 x 2 LCD module with the AT89S51 microcontroller as shown above. Resistor R3, capacitor C3, and button switch S1 will form the reset circuit. Crystal X1 and ceramic capacitors C1 and C2 are connected to the clock circuit that will produce the system clock frequency. The pins P1.0 to P1.7 of the microcontroller of the DB0 module are connected to the DB7 pins respectively, and this path is the data transmitted to the LCD module. The P3.3, P3.3, and P3.5 connect to the E, R/W, and RS pins of the microcontroller, and this directs the control signals that are transmitted to the LCD module. Resistor R1 limits the current through the LED backlight and the intensity of the backlight. POT R2 is used to adjust the screen contrast. Program to connect the LCD to 8051 microcontrollers as shown below.

Program to connect LCD to 8051 microcontroller

MOV A, #38H // Use two lines and a 5 x 7 . matrix

ACALL CMND

MOV A, #0FH // LCD ON, indicator ON, indicator ON

ACALL CMND

MOV A, #06H // Increase Indicator

ACALL CMND

MOV A, #82H // first cursor line, position 2

ACALL CMND

MOV A, #3CH // activate the second line

ACALL CMND

Move A, No. 49 D

ACALL DISP

Move A, No. 54 D

ACALL DISP

Move A, #88 D

ACALL DISP

Move A, No. 50 D

ACALL DISP

Move A, No. 32 D

ACALL DISP

Move A, No. 76 D

ACALL DISP

Move A, #67 D

ACALL DISP

Move A, #68 D

ACALL DISP

MOV A, #0C1H // Go to second line, position 1

ACALL CMND

Move A, #67 D

ACALL DISP

Move A, #73 D

ACALL DISP

Move A, No. 82 D

ACALL DISP

Move A, #67 D

ACALL DISP

Move A, #85 D

ACALL DISP

Move A, #73 D

ACALL DISP

Move A, No. 84 D

ACALL DISP

Move A, No. 84 D

ACALL DISP

Move A, #83 D

ACALL DISP

Move A, No. 84 D

ACALL DISP

Move A, No. 79 D

ACALL DISP

Move A, #68 D

ACALL DISP

Move A, #65 D

ACALL DISP

Move A, #89 D

ACALL DISP

Here: SJMP here

CMND: MOV P1, A

CLR P3.5

CLR P3.4

SETB P3.3

CLR P3.3

reaction

Rit

DISP: MOV P1, A

SETB P3.5

CLR P3.4

SETB P3.3

CLR P3.3

reaction

Rit

DELY: CLR P3.3

CLR P3.5

SETB P3.4

MOV P1, #0FFh

SETB P3.3

Move A, p. 1

JB ACC.7, DELY

CLR P3.3

CLR P3.4

This is all about the LCD interface with 8051 microcontrollers. We believe that the information in this article is useful for you to better understand this project. Further, any queries regarding this article or any assistance in carrying out electrical and electronics projects, feel free to contact us through the contact in the comments section below. Here is a question for you, what is the code for LCD interaction with 8051 microcontrollers?