C code for display WELCOME TO ALL in 1st line on lcd:-
#include<reg51.h>
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
unsigned char arr1[]={0x0e,0x01,0x06,0x80,0x38};
unsigned char arr2[]={"Welcome To All"};
void command();
void display();
int j,k,l,m,n;
void delay()
{
int x,y;
for(x=0;x<=100;x++)
{
for(y=0;y<=1275;y++);
}
}
void main()
{
while(1)
{
for(j=0;j<5;j++)
{
P1=arr1[j];
command();
}
for(k=0;k<15;k++)
{
P1=arr2[k];
display();
}
}
}
void command()
{
rs=0;
rw=0;
en=1;
delay();
en=0;
}
void display()
{
rs=1;
rw=0;
en=1;
delay();
en=0;
}
Simulation in proteus:-
C code for display Welcome to all in 1st line and God bless you in 2nd line on lcd
#include<reg51.h>
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
unsigned char arr1[]={0x0e,0x01,0x06,0x80,0x38};
unsigned char arr2[]={"Welcome To All"};
unsigned char arr3[]={"God Bless You "};
void command();
void display();
int j,k,l,m,n;
void delay()
{ int x,y;
for(x=0;x<=100;x++)
{
for(y=0;y<=1275;y++);
}
}
void main()
{
while(1)
{
for(j=0;j<5;j++)
{
P1=arr1[j];
command();
}
for(k=0;k<15;k++)
{
P1=arr2[k];
display();
}
P1=0xc0;
command();
for(k=0;k<15;k++)
{
P1=arr3[k];
display();
}
}
}
void command()
{
rs=0;
rw=0;
en=1;
delay();
en=0;
}
void display()
{
rs=1;
rw=0;
en=1;
delay();
en=0;
}
No comments:
Post a Comment