source code:
//-----data display in LCD screen-----//
#include<reg51.h>
sfr ldata=0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit sw1=P3^0;
sbit sw2=P3^1;
sbit sw3=P3^2;
//sbit sw4=P3^3;
void lcdcmd(unsigned char valude);
void lcddata(unsigned char value);
void delay(unsigned int itime);
void main()
{ unsigned int i;
unsigned char x[30]={"THATI ANAND ELECTRONICS DEPT."};
unsigned char x1[30]={" HELLO WORLD WELCOME ECE"};
unsigned char x2[30]={"HELLO EINSTEIN HOW ARE YOU SIR"};
unsigned char c;
ldata=0x00;
rs=0;
rw=0;
en=0;
sw1=1;
sw2=1;
sw3=1;
//sw4=1;
while(1)
{
lcdcmd(0x38);
delay(25);
lcdcmd(0x0E);
delay(25);
lcdcmd(0x01);
delay(25);
lcdcmd(0x06);
delay(25);
lcdcmd(0x81);
delay(25);
if(sw1==0)
{
for(i=0;i<12;i++)
{
c=x[i];
lcddata(c);
delay(25);
}
lcdcmd(0x0C0);
delay(25);
for(i=12;i<30;i++)
{
c=x[i];
lcddata(c);
delay(25);
}
}
if(sw2==0)
{
for(i=0;i<12;i++)
{
c=x1[i];
lcddata(c);
delay(25);
}
lcdcmd(0x0C0);
delay(25);
for(i=12;i<30;i++)
{
c=x1[i];
lcddata(c);
delay(25);
}
}
if(sw3==0)
{
for(i=0;i<15;i++)
{
c=x2[i];
lcddata(c);
delay(25);
}
lcdcmd(0x0C0);
delay(25);
for(i=15;i<30;i++)
{
c=x2[i];
lcddata(c);
delay(25);
}
}
}
}
void lcdcmd(unsigned char value)
{
ldata=value;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void lcddata(unsigned char value)
{
ldata=value;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
Reviewed by haru
on
July 03, 2012
Rating:
No comments