0% found this document useful (0 votes)
5 views

LCD Interfacing program

The document provides an overview of interfacing a 16×2 LCD with an 8051 microcontroller, detailing the pin configuration and commands used for operation. It includes a C program example that demonstrates how to send commands and data to the LCD. The document serves as a guide for setting up and programming the LCD display in embedded systems projects.

Uploaded by

suraj.k2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

LCD Interfacing program

The document provides an overview of interfacing a 16×2 LCD with an 8051 microcontroller, detailing the pin configuration and commands used for operation. It includes a C program example that demonstrates how to send commands and data to the LCD. The document serves as a guide for setting up and programming the LCD display in embedded systems projects.

Uploaded by

suraj.k2022
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Interfacing 16×2 LCD with 8051 microcontroller:

A 16×2 LCD display is a very basic module and is very commonly used in various devices and circuits.
16×2 Liquid Crystal Display which will display the 32 characters at a time in two rows (16 characters
in one row). Each character in the display is of size 5×7 pixel matrix.

16×2 LCD Pin Diagram:

Pin Description :

Sr No Name Function
1 VSS ground
2 VDD power supply ( +5V )
3 VEE contrast
4 RS register select
5 R/W read / write 0=write 1=read
6 E enable
7-14 Data Data lines
15 A Anode ( LCD Backlight )
16 K Cathode ( LCD Backlight )

LCD commands:

Sr No. Command Purpose


1 0x01 Clear Screen
2 0x02 Return Home
3 0x04 Decrement/Shift Cursor Left
4 0x05 Shift Display Right
5 0x06 Increment/Shift Cursor Right
6 0x07 Shift Display Left
7 0x08 Display Off, Cursor Off
8 0x0A Display Off, Cursor On
9 0x0C Display On, Cursor Off
Sr No. Command Purpose
10 0x0E Display On, Cursor On
11 0x0F Display On, Cursor Blink
12 0x10 Shift cursor position to left
13 0x14 Shift cursor position to Right
14 0x18 Shift entire display to left
15 0x1C Shift entire display to Right
16 0x80 Force cursor to beginning of 1st line
17 0xC0 Force cursor to beginning of 2nd line
18 0x38 2 lines 5x7 matrix

C – Program :

#include<AT89X52.h> //header file


#define RS P2_0 //register select pin
#define RW P2_1 //read/write pin
#define EN P2_2 //enable pin
#define PORT P1
void delay(); //delay function
void com(char ); //to send command to LCD
void dat(char ); //to send data to LCD
void print(char ); //our function to print the name.
int i,n=0;
com(0x0c); // display on cursor off
com(0x01); //clear screen
while(text[i]!='\0'){ //continue to print till we get the null character
// this block is intentionally commented. to be used when printing more than 16 characters
/* if(i>15){
com(0x1c); //shift display left
com(0x0c);
}
*/
print(text[i]);
i++;
}
while(9);
}
}

void print(char c){


com(0x06); // shift cursor to right >>>>>>
dat(c); // pass the character to LCD
}

void delay(){
short int i;
for(i=0;i<=255;i++);
}
void com(char m){
PORT=m;
RS=0;
RW=0;
EN=1;
delay();
EN=0;
delay();
}

void dat(char m){


PORT=m;
RS=1;
RW=0;
EN=1;
EN=0;
delay();
}

You might also like