dolphinlabs
...
Doplhin labs
News

LCD Interfacing


·         Program Statement : Interfacing of LCD with 89C51 microcontroller.

Connections : P1.0=RS , P1.1=RW, P1.2=EN(control lines of LCD                                     

                                  P0.0-P0.7=D0-D7(Data lines of LCD)

 

Hardware Connections for 8051 Board:-

1.      Give supply to 8051 board with the help of adapter

2.       Connect +5V pin of 8051 microcontroller to +5V supply and GND pin of 8051 microcontroller to GND pin of supply.

3.      Connect +5V pin of RS232 interface to +5V supply and GND pin of RS232 interface to GND pin of supply.

4.      Connect R2OUT pin of RS232 interface to RXD pin of 8051 and T2IN pin of RS232 interface to TXD pin of 8051.

5.      Connect +5V pin of LCD interface to +5V supply pin and GND pin of LCD interface to GND pin of supply.

6.      Connect RS pin of LCD to P1.0 pin of microcontroller.

7.      Connect RW pin of LCD to P1.1 pin of microcontroller.

8.      Connect EN pin of LCD to P1.2 pin of microcontroller.

9.      Connect data pins of LCD D0-D7 to P0.0-P0.7 pins of microcontroller by using bus.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Circuit Diagram:

 

 

 

 

 

 

 

 

 

 

 

Program Code:

#include<reg51.h>

#include<stdio.h>

sbit RS =P1^0;                                       // select single bit P1.0 and name it as RS

sbit RW =P1^1;                                     //select single bit P1.1 and name it as RW

sbit EN =P1^2;                                      //select single bit P1.2 and name it as EN

void delay();

void lcddata(unsigned int);

void lcdcmd(unsigned int);

void main()

{

unsigned char msg[]="Dolphin Labs";

int i;

P0=0x00;

lcdcmd(0x38);                                       //Initialize LCD

lcdcmd(0x01);                                      // clear LCD

lcdcmd(0x0e);                                        //display on cursor on

lcdcmd(0x06);                                       // right shift

lcdcmd(0x80);                                       // cursor on first line

 

for(i=0;i<sizeof(msg);i++)

 {

 lcddata(msg[i]);        

 delay();

 }

}

void lcdcmd(unsigned int x)

{

P0=x;

RS=0;                                     //for command lines RS=0

RW=0;                                    //RW is 0 for write operation

EN=1;                                    //enable LCD operation

delay();

EN=0;                                    //disable LCD operation

}

void lcddata(unsigned int y)

{

P0=y;

RS=1;                                     //RS=1 for data lines

RW=0;      

EN=1;

delay();

EN=0;

}

void delay()

{

int i,j;

for(i=0;i<10000;i++);

for(j=0;j<255;j++);

}

 

 

 

 

 

 

 


Get SOCIAL







SAFE & SECURE SHOPPING

visa card master card maestro card
Maverick IT Industries Pvt. Ltd.