LCD interfacing using 8051 Micro-Controller

SOFTWARE: KEIL MICRO VISION 4.0


SIMULATOR: PROTEUS 8.0


CIRCUIT DIAGRAM:





PIN DESCRIPTION OF LCD:




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,5x8 dots
lcd_command(0x01); // clear display
lcd_command(0x0f); //display on,cursor blinking
lcd_command(0x06);
lcd_command(0x80); // force cursor to beginning 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 the lcd command function, to pass that commands I have select RS(p2.0) as '0' 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 the command, I have sent data (which needs to be displayed on lcd) which is in a string format to string function. In the string function, I have provided one by one character of a string in an array format to the lcd data function. In the lcd data function, one by one character is provided to port 1.
In the lcd data function, all the operations remain the same as getting performed in the lcd command function. Only RS(p2.0) is provided with '1' to select the data register.

VIDEO:







NOTE:

In proteus simulation,there is no need to connect vss,vdd and vee.But when we are practically implementing the circuit,all the pins should be connected as mentioned in pin description table of lcd.

Comments

Popular posts from this blog

Digital Thermometer using 8051 and ADC 0808 Interfacing With 8051

how to display numbers on lcd?

To display custom characters on the lcd using 8051 micro-controller.