top of page
Search

Project Name: LCD interfacing using 8051 Micro-Controller

sujata redkar

Software: KEIL micro vision 4.0


Simulator :Proteus 8.0


Circuit diagram:



Program:


#include<reg51.h>

sbit RS = P2^0; // REGISTER SELECT

sbit RW = P2^1; // READ/WRITE

sbit EN = P2^2; // ENABLE

void delay(int t); //delay function

void lcd_init(void); //initialization of lcd

void lcd_command(char c); // lcd command function

void lcd_data(char d); //lcd data function

void str(char a[]); // lcd string function


void main() // main program

{

lcd_init();

str("welcome"); // data to be displayed on lcd.

while(1);

}


void lcd_init(void)

{

lcd_command(0x38); //8 bit,2 line,5x7 dots

lcd_command(0x01); // clear dispay

lcd_command(0x0f); //display on,cursor blinking

lcd_command(0x06);

lcd_command(0x80); // force cursor to begining of first row

}


void lcd_command(char c)

{

P1=c; //send command to port1

RS=0; //select command register to send command

RW=0; // write operation

EN=1; // send high to low pulse on enable pin of lcd

delay(5);

EN=0;

delay(5); // delay

}


void lcd_data(char d)

{

P1=d; //send data to port1

RS=1; //select data register to send data

RW=0; // write operation

EN=1; // send high to low pulse on enable pin of lcd

delay(5);

EN=0;

delay(5); // delay

}


void delay(int t)

{

int j;

for(j=0;j<t*1275;j++);

}


void str(char a[])

{

int j;

for(j=0;a[j]!='\0';j++)

{

lcd_data(a[j]); //pass string to array

}

}


Program Description:


First I have initialized the lcd by providing various lcd commands.In lcd command function,in order to pass that commands I have select RS(p2.0) as '0' in order to select command register.After that to enable write operation R/W(p2.1) is provided with '0'.To pass that commands to lcd I have provided high to low pulse on EN(p2.2) of lcd.


After passing command,I have send data (which needs to be displayed on lcd) which is in a string format to string function.In string function I have provided one by one character of string in array format to lcd data function.In lcd data function one by one character is provided to port 1.


In lcd data function all the operations remain same as in the lcd command function only RS(p2.0) is provided with '1' in order to select data register.Delay is provided in between for synchronization.


Video:







27 views0 comments

Comments


bottom of page