4 Resistors
R1 470
R21k
R3, R4 10k
2 Capacitors
Quantity: References Value
2 C1, C2 33p
2 Integrated Circuits
Quantity: Reference Value
1 U2 OPTOCOUPLER-NPN
1 U3 AT89C51
1 Transistors
Quantity: References Value
1 Q1 NPN
2 Diodes
Quantity: References Value
1 D1 DIODE
1 D2 LED
7 Miscellaneous
Quantity: References Value
2 B1, RL1 6v
1 L1 12V
1 LCD2 LM016L
2 SW1, SW2 SW-SPST
1 X1 CRYSTAL
C-PROGRAM
#include
#include
#define COL P3
#define ROW P0
//sfr ldata=0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit access=P2^3;
char master_password[6]="22222";
void delay(unsigned int itime);
void lcdcmd(unsigned char value);
void lcddata(char *value);
void keyboard_reading(char );
void keyboard_key_press();
unsigned char keyboard[4][3]={ '1','2','3',
'4','5','6',
'7','8','9',
'*','0','#',};
char temporary_storage[6];
int i;
char ch;
void main()
{
while(1)
{
access=0;
lcdcmd(0x38);
delay(50);
lcdcmd(0x0e);
delay(50);
lcdcmd(0x01);
delay(25);
lcdcmd(0x06);
delay(50);
lcdcmd(0x81);
//delay(250);
lcddata("WELCOME");
//delay(250);
lcdcmd(0xc0);
lcddata("ENTER PASSWORD");
ch=0;
keyboard_key_press();
//password comparision
if(strcmp(master_password,temporary_storage)==0)
{
lcdcmd(0x01);
lcdcmd(0x81);
delay(25);
lcddata("THANKS");
lcdcmd(0xc1);
lcddata("YOU CAN ENTER");
access=1;
delay(25);
}
else
{
for(i=0;i<3;i++)
{
lcddata("PASSWORD IS WRONG");
delay(25);
lcdcmd(0x01);
lcddata("ENTER ONCE AGAIN");
delay(25);
ch=0;
keyboard_key_press();
if(strcmp(master_password,temporary_storage)==0)
{
lcdcmd(0x01);
lcdcmd(0x81);
delay(25);
lcddata("THANKS, YOU CAN ENTER");
access=1;
delay(1000);
delay(1000);
delay(1000);
delay(1000);
break;
}
lcdcmd(0x01);
if(i==2)
{
lcdcmd(0x01);
lcdcmd(0x81);
lcddata("INVALID PASSWORD");
lcdcmd(0xc1);
lcddata("CONTACT ADMINISTRATOR");
}
}
}
}
}
//functions declarations
void keyboard_reading(char value)
{
if(ch==0)
{
lcdcmd(0x01);
lcdcmd(0x81);
}
temporary_storage[ch]=value;
ch++;
// lcdcmd(0x01);
// lcdcmd(0x81);
delay(50);
lcddata("*");
// delay(100);
if(ch==5)
temporary_storage[ch]='\0';
return;
}
void lcdcmd(unsigned char value)
{
P1=value;
rs=0;
rw=0;
en=1;
delay(10);
en=0;
return;
}
void lcddata(char *value)
{
int m;
for(m=0;value[m]!='\0';m++)
{
delay(1);
P1=value[m];
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++);
}
void keyboard_key_press(void )
{
unsigned char colloc,rowloc;
//P0=0xff;
int m;
// COL=0xff;
for(m=0;m<=4;m++)
{
do
{
// delay(100);
ROW=0x00;
colloc=COL;
colloc&=0x0f;
}
while(colloc!=0x0f);
do
{
do
{
delay(20);
colloc=COL;
colloc&=0x0f;
}while(colloc==0x0f);
delay(20);
colloc=COL;
colloc&=0x0f;
} while(colloc==0x0f);
while(1)
{
ROW=0xfe;
colloc=COL;
colloc&=0x0f;
if(colloc!=0x0f)
{
rowloc=0;
break;
}
ROW=0xfd;
colloc=COL;
colloc&=0x0f;
if(colloc!=0x0f)
{
rowloc=1;
break;
}
ROW=0xfb;
colloc=COL;
colloc&=0x0f;
if(colloc!=0x0f)
{
rowloc=2;
break;
}
ROW=0xf7;
colloc=COL;
colloc&=0x0f;
rowloc=3;
break;
}
if(colloc==0x0e)
keyboard_reading(keyboard[rowloc][0]);
else if(colloc==0x0d)
keyboard_reading(keyboard[rowloc][1]);
else if(colloc==0x0b)
keyboard_reading(keyboard[rowloc][2]);
else // (colloc==0x07)
keyboard_reading(keyboard[rowloc][3]);
}
}