16X2 LCD Interfacing With 8051 Controller | Source Code

This tutorial shows that how to interface 16X2 LCD with 8051 controller circuit design and source code.

Components Required:

  • AT89C51
  • 16×2 LCD
  • Potentiometer 10k
  • Crystal Oscillator 12MHZ
  • Power Supply

The source Code :

 // Program to display dynamic text on LCD 

#include<reg51.h>
sbit rs=P3^0;   //Register select (RS)
sbit rw=P3^1;   //Read write (RW) pin
sbit en=P3^2;   //Enable (EN) pin

char name[]={"ARVIN SINGH TUTORIAL"};    //String to be displayed on LCD

void delay(unsigned int time)  //Time delay function
{
unsigned int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}

void lcdcmd(unsigned char value)  //Function for sending values to the command register of LCD
{
P2=value;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void display(unsigned char value)  //Function for sending values to the data register of LCD
{
P2=value;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void main()
{
int i;
lcdcmd(0x38);
lcdcmd(0x0e);
lcdcmd(0x06);
lcdcmd(0x80);

for(i=0;name[i]!='\0';i++)  //Sending string to LCD
{
  display(name[i]);
  delay(10);
}


while(1)
{
  lcdcmd(0x1c);  //Shift the entire display to right
  delay(30);
}
}

To view more :

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *