#include <REGX51.H>
sfr ldata = 0x90; //P1 = LCD data pins
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
unsigned char k,d1,d2,d3,d4,p1,p2,p3,p4,count,x;
code unsigned char line1[16]="S.V.I.T. VASAD. ";
code unsigned char line2[16]="Etr Password ";
code unsigned char line3[16]="Etr Password ";
code unsigned char line4[16]="Dharam..........";//0246
code unsigned char line5[16]="Shashwat........";//0123
code unsigned char line6[16]="Pritesh.........";//9630
code unsigned char line7[16]="Devansh.........";//9876
code unsigned char line8[16]="Access Denied...";
code unsigned char line9[16]="Mayur...........";//ABCD
code unsigned char line10[16]="Elec & comm dept";//ABCD
void lcdcmd (unsigned char value);
void lcddata (unsigned char value);
void MSDelay (unsigned int itime);
void main (void)
{
P0 = 0xFF;
lcdcmd(0x38); // 2 line & 5*7 matrix
MSDelay(1);
lcdcmd(0x0C); // display on cursor off
MSDelay(1);
lcdcmd(0x01); // clear display screen
MSDelay(1);
lcdcmd(0x80); // line 1, position 0
MSDelay(1);
for(k=0;k<16;k++)
{
lcddata(line1[k]);
MSDelay(1);
}
d1=d2=d3=d4=p1=p2=p3=p4=0;
count=0;
while(1)
{
P0_3 = 0; //selecting the Row 0
{
if(P0 == 0x77)
{
while(P0==0x77);
count++;
x=0;
}
if(P0==0xB7)
{
while(P0==0xB7);
count++;
x=1;
}
if(P0 == 0xD7)
{
while(P0==0xD7);
count++;
x=2;
}
if(P0 == 0xE7)
{
while(P0==0xE7);
count++;
x=3;
}
}
P0_3 = 1; //Row 0 off
P0_2 = 0; //Selecting the Row 1
{
if(P0 == 0x7B)
{
while(P0==0x7B);
count++;
x=4;
}
if(P0==0xBB)
{
while(P0==0xBB);
count++;
x=5;
}
if(P0 == 0xDB)
{
while(P0==0xDB);
count++;
x=6;
}
if(P0 == 0xEB)
{
while(P0==0xEB);
count++;
x=7;
}
}
P0_2 = 1; //Row 1 off
P0_1 = 0; //Selecting the Row 2
{
if(P0 == 0x7D)
{
while(P0==0x7D);
count++;
x=8;
}
if(P0==0xBD)
{
while(P0==0xBD);
count++;
x=9;
}
if(P0 == 0xDD)
{
while(P0==0xDD);
count++;
x='A';
}
if(P0 == 0xED)
{
while(P0==0xED);
count++;
x='B';
}
}
P0_1 = 1;
P0_0 = 0; //Selecting the Row 3
{
if(P0 == 0x7E)
{
while(P0==0x7E);
count++;
x='C';
}
if(P0==0xBE)
{
while(P0==0xBE);
count++;
x='D';
}
if(P0 == 0xDE)
{
while(P0==0xDE);
count++;
x='E';
}
} //Row 2 off
P0_0 = 1;
if(count==1)
{
d1=x;
p1='*';
}
if(count==2)
{
d2=x;
p2='*';
}
if(count==3)
{
d3=x;
p3='*';
}
if(count==4)
{
d4=x;
p4='*';
}
lcdcmd(0xC0); // line 1, position 0
MSDelay(1);
if(count==0)
{
for(k=0;k<16;k++)
{
lcddata(line2[k]);
MSDelay(1);
}
}
if(count==1 || count==2 || count==3 || count==4)
{
for(k=0;k<16;k++)
{
if( k<12)
lcddata(line3[k]);
if(k==12)
lcddata(p1);
if(k==13)
lcddata(p2);
if(k==14)
lcddata(p3);
if(k==15)
lcddata(p4);
MSDelay(1);
}
}
P0_0 = 0; //Selecting the Row 3
{
if(P0 == 0xEE)
count=5;
}
P0_0 = 1;
if(count==5)
{
if(d1==0 && d2==2 && d3==4 && d4==6)
{ lcdcmd(0x80); // line 1, position 0
MSDelay(1);
for(k=0;k<16;k++)
{
lcddata(line4[k]);
MSDelay(1);
}
lcdcmd(0xC0); // line 2, position 0
MSDelay(1);
for(k=0;k<16;k++)
{
lcddata(line10[k]);
MSDelay(1);
}
}
else if(d1==0 && d2==1 && d3==2 && d4==3)
{
for(k=0;k<16;k++)
{
lcddata(line5[k]);
MSDelay(1);
}
}
else if(d1==9 && d2==6 && d3==3 && d4==0)
{
for(k=0;k<16;k++)
{
lcddata(line6[k]);
MSDelay(1);
}
}
else if(d1==9 && d2==8 && d3==7 && d4==6)
{
for(k=0;k<16;k++)
{
lcddata(line7[k]);
MSDelay(1);
}
}
else if(d1=='A' && d2=='B' && d3=='C' && d4=='D')
{
for(k=0;k<16;k++)
{
lcddata(line9[k]);
MSDelay(1);
}
}
else
{
for(k=0;k<16;k++)
{
lcddata(line8[k]);
MSDelay(1);
}
}
}
}
}
void lcdcmd (unsigned char value)
{
ldata = value; // put value on the pins
rs = 0;
rw = 0;
en = 1; // strobe the enable pin
MSDelay(1);
en = 0;
return;
}
void lcddata (unsigned char value)
{
ldata = value; // put the value on the pins
rs = 1;
rw = 0;
en = 1; // strobe the enable pin
MSDelay(1);
en = 0;
return;
}
void MSDelay (unsigned int itime)
{
unsigned int i,j;
for(i=0; i<itime; i++)
{
for(j=0; j<100; j++)
{;}
}
}