INTERFACING LCD WITH 8051 MIROCONTROLLER With Code
INTERFACING LCD WITH 8051 MIROCONTROLLER With Code
INTERFACING LCD WITH 8051 MIROCONTROLLER With Code
Menu
INTERFACING LCD WITH 8051 MIROCONTROLLER: In this article you will learn
how to interface lcd with 8051 microcontroller. It is not very hard for interfacing
lcd with 8051 microcontroller when you already know how to use kiel for
programming of 8051 and how to used input output ports of 8051
microcontroller. LCD is used for displaying alphabets, numbers or some
messages etc. We already learnt about the use of LCD using PIC microcontroller
in previous article. Now in this tutorial we will study how to interface LCD with
8051 microcontroller. 8051 is basic level of using controllers, so it’s a bit difficult
as compared to PIC microcontroller and LCD interfacing code is also changed
here. you can also scroll text on lcd as we did in pic microcontroller tutorial.
Table of Contents
16×2 LCD:
We can use any type of LCD like 16×2, 8×1, 16×4, 8×2, 16×1, 20×1, 20×2 etc. Here
we will use 16×2 Liquid Crystal Display. It can display 32 characters at a time in
two rows. LM016L is a 16×2 LCD module.There are 16 pins in this LCD module,
the pin configuration us given below:
LCD PIN DIAGRAM:
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 1/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
Pin 4 RS (command register when low, data register when high)
Pin 5 R/W (high for read from register, low for write to the register)
Pin 6 EN (sends data to data pins when high to low pulse is given)
Data register
Command register
Data register: It is for placing the data which is to be displayed. Data can be any
character, alphabet or number.High logic at the RS pin will select the data
register. By making RS pin high and putting data in the 8 bit data line (DB0 to
DB7), the LCD module will recognize it as a data to be displayed.
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 2/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
R/W pin is for selecting between read and write modes. High level at this pin
enables read mode and low level at this pin enables write mode.
DB0 to DB7 are the data pins. The data to be displayed and the commands are
placed on these pins.
For glowing backlight LED, LED+ (anode of back light LED)is connected to Vcc
through a suitable series current limiting resistor (for contrast adjustment). LED-
(cathode of the back light LED) is connected to ground.
This LCD can be operated in 4-bit mode (using only 4 data lines) or 8-bit mode
(using all 8 data lines). Here we will useit in 8-bit mode. First of all LCD is
initialized and then it can be used for sending data and commands. Reset and
Enable of LCD is connected to port 1 of 8051 microcontroller. Data lines of LCD
are connected to port 2 of 8051 microcontroller. R/W is connected to ground
since we have to just write data and command (not read operation). This gives a
little ease so that we don’t need to make this pin low in the code.
TO SENDDATA:
TO SEND COMMAND:
To instruct LCD for performing specific task for example displaying character in
second row instead of one, following steps should be taken:
#include<reg51.h>
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 5/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
voidlcd_init(void);
voidwritecmd(int);
voidwritedata(char);
void delay(int);
sbit RS = P1^0;
sbit E = P1^1;
inti=0;
void main()
led = 1;
lcd_init();
writedata('W');
delay(5000000);
writedata('e');
delay(5000000);
writedata('l');
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 6/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
delay(5000000);
writedata('c');
delay(5000000);
writedata('o');
delay(5000000);
writedata('m');
delay(5000000);
writedata('e');
delay(5000000);
writedata(' ');
delay(5000000);
writedata('T');
delay(5000000);
writedata('o');
delay(5000000);
writedata('w');
writedata('w');
writedata('w');
writedata('.');
writedata('m');
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 7/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
writedata('i');
writedata('c');
writedata('r');
writedata('o');
writedata('c');
writedata('o');
writedata('n');
writedata('t');
writedata('r');
writedata('o');
writedata('l');
writedata('l');
writedata('e');
writedata('r');
writedata('s');
writedata('l');
writedata('a');
writedata('b');
writedata('.');
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 8/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
writedata('c');
writedata('o');
writedata('m');
delay(5000000);
delay(5000000);
delay(5000000);
delay(5000000);
void lcd_init(void)
RS = 1;
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 9/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
E = 1;
delay(150);
E = 0;
delay(150);
RS = 0;
E = 1;
delay(150);
E = 0;
delay(150);
inti;
for(i=0;i<a;i++); }
Email Address
SUBSCRIBE
Getachew Nega
February 22, 2017 at 5:34 pm
Thanks for the invaluable information. But I have a question for you, how
much second is the delay given by delay(5000000) and delay(150)?
Thanks in advance for your feedback!
Reply
fasil
December 27, 2020 at 11:58 pm
Reply
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 11/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
Leave a Comment
Name *
Email *
Website
POST COMMENT
8051 Tutorials
Getting Started 8051
LED blinking 8051
LCD Interfacing 8051
Keypad Interfacing
DC Motor Interfacing
8051 Timers
External Interrupts 8051
ADC0804 Interfacing
EEPROM interfacing
Optocoupler interfacing
serial communication 8051
Email Address
SUBSCRIBE
Categories
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 13/14
9/5/21, 10:25 AM INTERFACING LCD WITH 8051 MIROCONTROLLER with code
Select Category
Recent Posts
ESP32 Server Client Wi-Fi Communication using Arduino IDE
ESP32 Web Server Hosting Files from Micro SD card (Arduino IDE)
OLED Display Interfacing with ESP32 – Display Text, Draw shapes and Images
ESP32 Data Logging Temperature Sensor Readings to microSD card (Arduino IDE)
Copyright © 2013-2021
Microcontrollerslab.com All Rights Reserved
https://microcontrollerslab.com/interfacing-lcd-8051-mirocontroller-code/ 14/14