Interfacing A Lcd Display With 8051.docx

  • Uploaded by: bhaswati
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Interfacing A Lcd Display With 8051.docx as PDF for free.

More details

  • Words: 591
  • Pages: 7
Interfacing a LCD display with 8051 microcontroller and displaying a character on LCD LCD is a very commonly used output device to display alphanumeric characters. The LCD displays the character corresponding to the data received on its input data port i.e., it treats the data as the ASCII value of the character to be displayed. So if the value 65 is given to its data port the character “A” will be displayed and if the value 49 is given to the LCD the numeric digit “1” will be displayed. At many instances it is required to display a number like 123 on LCD. Displaying this number is tricky. If the data port of the LCD is loaded with the number 123, then the character corresponding to it will be displayed. LCD INTERFACING WITH 8051 IN 8-BIT MODE Here we use a 16x2 LCD which is interfaced by P89V51RD2 which is a 8051 microcontroller. Pin configuration is written behind this LCD as... 1 2 3 4 5 6 7-14 15 16

-

GND VCC (+5V) VEE (FOR CONTRAST) RS (REGISTER SELECT) RW (READ/WRITE) EN (ENABLE) DATA PINS D0-D7 LED PLUS LED MINUS

Components required:1. 2. 3. 4. 5. 6. 7.

10uf electrolytic capacitor 10k ohm registance 10k ohm variable registance 11.059 MHZ crystal oscilltor 16x2 LCD P89V51RD2 IC 5v battery

Circuit diagram:

Platform: P89V51RD2 Development Board (Model No.SK-0001-DB).

Pin Function:Port1 is connected to the data port of LCD. P0.5 is connected to the RS(Register Select) Pin of the LCD. P0.6 is connected to the R/W(Read/Write) Pin of the LCD. P0.7 is connected to the E(Enable) Pin of the LCD.

PROGRAM #include #define ldata P2 // port2 is defined as ldata sbit RS= P0^5;

// register select pin is defined

sbit RW= P0^6;

//read/write pin is defined

sbit EN= P0^7;

//enable pin is defined

unsigned char mess1[]="PHYSICSLAB:"; unsigned char mess2[]="ELECTRONIC

//message1 to displayed in the 1st line "; //message1 to displayed in the 2nd line

unsigned char mess3[]="Implementation"; //message1 to displayed in the 2nd line unsigned char mess4[]="

"; //message1 to displayed in the 2nd line

/**************************************** function for giving a delay of millisecond *****************************************/ void delay_ms(unsigned int xtime) { unsigned int i,j; for(i=0;i<xtime;i++) for(j=0;j<1275;j++); }

/**************************************** function for sending command to lcd *****************************************/ void lcdcmd(unsigned char value) {

ldata = value; // value is copied to ldata RS=0; // since RS=0 "command register" of lcd is selected RW=0; // since RW=0 lcd goes to write mode EN=1; // lcd is enabled delay_ms(1);

//delay for 1ms

EN=0; // lcd is disabled }

/**************************************** function for sending data to lcd *****************************************/ void lcddata(unsigned char value) { ldata=value; RS=1; // since RS=1 "data register" of lcd is selected RW=0; EN=1; delay_ms(1); EN=0; }

/**************************************** function for initializing lcd *****************************************/ void initialize_lcd() { lcdcmd(0x38); //2 line and 5x7 matrix

delay_ms(10); //delay lcdcmd(0x0c); // display on cursor off //

lcdcmd(0x0e); // display on cursor blinking delay_ms(10); lcdcmd(0x01); //clear display screen delay_ms(10); lcdcmd(0x06); //Increament cursor to right delay_ms(10); lcdcmd(0x83); //force cursor to position 4th position of line1 delay_ms(10); }

void main (void) { unsigned char z,m; initialize_lcd();

// char variable is defined as Z; // function call to initialize LCD

/*Display Ist message*/ for(z=0;z<11;z++) { lcddata(mess1[z]);

// function call for sending data to LCD

}

while(1) { /*Display 2nd message*/ for(z=0xCF;z>=0xC4;z--)

{ lcdcmd(z); for( m=0;m<14;m++) { lcddata(mess2[m]); } } delay_ms(100);

for(z=0xCF;z>=0xC0;z--) { lcdcmd(z); for( m=0;m<16;m++) { lcddata(mess4[m]); } } delay_ms(100);

lcdcmd(0xc8); lcddata('&'); delay_ms(100); lcdcmd(0xc8); lcddata(' '); delay_ms(100);

for(z=0xCF;z>=0xC2;z--)

{ lcdcmd(z); for( m=0;m<14;m++) { lcddata(mess3[m]); } } delay_ms(100);

for(z=0xCF;z>=0xC0;z--) { lcdcmd(z); for( m=0;m<16;m++) { lcddata(mess4[m]); } }

} }

Related Documents


More Documents from ""

Radar Problem.docx
December 2019 10
Time_table_2018.docx
December 2019 8
Manual.docx
December 2019 10
Laboratory Manual.docx
December 2019 17