code:
#include<reg51.h>
sfr lcd_data_pin=0xA0; // data port P2
sbit rs=P0^0; // Register select pin
sbit rw=P0^1; // Read write pin
sbit en=P0^2; // Enable pin
void delay(unsigned int msec) //delay function
{
int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void lcd_command(unsigned char comm) // function to send command to LCD
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(1);
en=0;
}
void lcd_data(unsigned char disp) // function to send data on LCD
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(1);
en=0;
}
lcd_dataa(unsigned char *disp) // function to send string to LCD
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}
void lcd_ini() //Function to inisialize the LCD
{
lcd_command(0x38);
delay(5);
lcd_command(0x01);
delay(5);
lcd_command(0x0C);
delay(5);
lcd_command(0x80);
delay(5);
}
void main()
{
lcd_ini();
lcd_dataa(" pandya"); //place your text
lcd_command(0xc0);
lcd_dataa("electronics");
while(1) //function that scroll the message
{
delay(100);
lcd_command(0x05);
}
}
Circuit Diagram:
PandyaElectronics' prototype:
check out video:
#include<reg51.h>
sfr lcd_data_pin=0xA0; // data port P2
sbit rs=P0^0; // Register select pin
sbit rw=P0^1; // Read write pin
sbit en=P0^2; // Enable pin
void delay(unsigned int msec) //delay function
{
int i,j;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}
void lcd_command(unsigned char comm) // function to send command to LCD
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(1);
en=0;
}
void lcd_data(unsigned char disp) // function to send data on LCD
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(1);
en=0;
}
lcd_dataa(unsigned char *disp) // function to send string to LCD
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
}
}
void lcd_ini() //Function to inisialize the LCD
{
lcd_command(0x38);
delay(5);
lcd_command(0x01);
delay(5);
lcd_command(0x0C);
delay(5);
lcd_command(0x80);
delay(5);
}
void main()
{
lcd_ini();
lcd_dataa(" pandya"); //place your text
lcd_command(0xc0);
lcd_dataa("electronics");
while(1) //function that scroll the message
{
delay(100);
lcd_command(0x05);
}
}
Circuit Diagram:
PandyaElectronics' prototype: