You are on page 1of 15

8051 password C Program | Embed4u

1 of 15

http://www.embed4u.com/8051-password-c-program/

Embed4u
All About Embedded Hardware and Software
Home
Code Library
DOWNLOAD
Drivers
Electronics
Projects
Related Videos
Schematics
Technology
Tutorial

Ads by Google

Password

Password Program

Word Password

8051

Home > Code Library > 8051 password C Program

8051 password C Program


November 27th, 2009 admin Leave a comment Go to comments

#include<reg51.h>
#include<string.h>
void get_column();
void get_columnp();
void delay1();
void displayp();

5/23/2012 3:50 PM

8051 password C Program | Embed4u

2 of 15

http://www.embed4u.com/8051-password-c-program/

void disp();
sbit rs=P0^0;
sbit rw=P0^1;
sbit entrans=P3^7;
sbit st=P0^7;
sbit enlcd=P3^4;
sbit enlat=P2^7;
sbit lock1=P2^0;
sbit b=P2^6;
int key1[4][3]={1,2,3,4,5,6,7,8,9,*',0,#'};
int chk,r,c,l,pa,word,pass,den1;
int dela;
void calldelay();
void timeopen();
void init_timer0();
void read()
{
P1=096;
while(P1==096){}
{
if(P1==092)r=0;
if(P1==094)r=1;
if(P1==086)r=2;
if(P1==016)r=3;
get_column();
}
}
void get_column()

5/23/2012 3:50 PM

8051 password C Program | Embed4u

3 of 15

http://www.embed4u.com/8051-password-c-program/

{
P1=068;
while(P1==068){}
if(P1==048)c=0;
if(P1==028)c=1;
if(P1==060)c=2;
disp();
delay1();
}
void readp()
{
P1=096;
while(P1==096){}
{
if(P1==092)r=0;
if(P1==094)r=1;
if(P1==086)r=2;
if(P1==016)r=3;
get_columnp();
}
}
void get_columnp()
{
P1=068;
while(P1==068){}
if(P1==048)c=0;
if(P1==028)c=1;
if(P1==060)c=2;

5/23/2012 3:50 PM

8051 password C Program | Embed4u

4 of 15

http://www.embed4u.com/8051-password-c-program/

displayp();
delay1();
}
void delay()
{
int j;
for(j=0;j<1000;j++)
{
}
}
void delay1()
{
int i,j;
for(i=0;i<=260;i++)
for(j=0;j<=500;j++)
{}
}
void enter()
{
if(r==3&&c==2)
{
l=0;
}
}
void commandmode()
{
rs=0;
rw=0;

5/23/2012 3:50 PM

8051 password C Program | Embed4u

5 of 15

http://www.embed4u.com/8051-password-c-program/

}
void datamode()
{
rs=1;
rw=0;
}
void enablelatch()
{
int k=1000;
enlat=1;
while(k)
{}
enlat=0;
}
void enablelcd()
{
int h=1000;
enlcd=1;
while(h)
{}
enlcd=0;
}
void enabletrans()
{
entrans=1;
}
void init_lcd()
{

5/23/2012 3:50 PM

8051 password C Program | Embed4u

6 of 15

http://www.embed4u.com/8051-password-c-program/

int j;
char a[4]={038,001,00e,080};
for(j=0;j<=3;j++)
{
commandmode();
enablelatch();
P0=a[j];
enabletrans();
enablelcd();
}
}
void secondline()
{
commandmode();
enablelatch();
P0=0xc0;
enabletrans();
enablelcd();
}
void display()
{
datamode();
enablelatch();
P0=(key1[r]+48);
enabletrans();
}
void displayp()
{

5/23/2012 3:50 PM

8051 password C Program | Embed4u

7 of 15

http://www.embed4u.com/8051-password-c-program/

datamode();
enablelatch();
P0=(key1[3][0]);
enabletrans();
enablelcd();
}
void displaystr(char *s)
{
int l=strlen(s);
int i;
for(i=0;i<=l-1;i++)
{
datamode();
enablelatch();
P0=s[i];
enabletrans();
enablelcd();
}
}
void displayint(int x)
{
datamode();
enablelatch();
P0=(x+48);
enabletrans();
enablelcd();
}
void disp()

5/23/2012 3:50 PM

8051 password C Program | Embed4u

8 of 15

http://www.embed4u.com/8051-password-c-program/

{
display();
}
void init_timer0()
{
dela=3000;
TR0=0;
TMOD=001;
IE=082;
TH0=0xdc;
TL0=000;
TR0=1;
}
void runtimer0()interrupt 1
{
TR0=0;
dela;
if(dela==3){P1=016;}
if(dela==1){P1=060;}
if(dela==0){l=0;}
TF0=0;
TH0=0xdc;
TL0=000;
TR0=1;
}
void timeopen()
{
l=1;

5/23/2012 3:50 PM

8051 password C Program | Embed4u

9 of 15

http://www.embed4u.com/8051-password-c-program/

init_timer0();
while(1)
{
read();
enter();
}
TR0=0;
l=1;
}
/*void calldelay()
{
int k=0;
for(k=0;k<30;k++)
{
read();
enter();
if(l==0)k=31;
dela=60000;
while(l){}
}
chk=0;*/
void main()
{
l=1;
lock1=1;
b=1;
den1=0;
init_lcd();

5/23/2012 3:50 PM

8051 password C Program | Embed4u

10 of 15

http://www.embed4u.com/8051-password-c-program/

displaystr(code lock);
secondline();
displaystr(security);
while(1)
{
read();
if(r!=3||c!=2)
{
init_lcd();
displaystr(press#);
}
enter();
}
l=1;
while(1)
{
init_lcd();
displaystr(enter code);
secondline();
while(1)
{
read();
if(pa==0){word=100*key1[r];}
if(pa==1){word=word+key1[r]*10;}
if(pa==2){word=word+key1[r];}
pa++;
enter();
}

5/23/2012 3:50 PM

8051 password C Program | Embed4u

11 of 15

http://www.embed4u.com/8051-password-c-program/

l=1;
pa=0;
if(word==123){
if(den1<2)
{
init_lcd();
displaystr(enter the pass);
secondline();
while(1)
{
read();
if(pa==0){pass=100*key1[r];}
if(pa==1){pass=pass+key1[r]*10;}
if(pa==2){pass=pass+key1[r];}
pa++;
enter();
}
l=1;
pa=0;
init_lcd();
if(pass==111)
{
displaystr(locker opened);
lock1=0;
timeopen();
lock1=1;
}
if(pass!=111)

5/23/2012 3:50 PM

8051 password C Program | Embed4u

12 of 15

http://www.embed4u.com/8051-password-c-program/

{
displaystr(denied);
den1++;
while(1){read();enter();}
l=1;
}
}
if(den1>=2)
{
init_lcd();
displaystr(contact admin);
b=0;
while(1)
{
read();enter();}
b=1;
l=1;
}
}}
}
Related posts:
1. RTC DS1307 INTERFACE WITH 8051 C PROGRAM
2. 34 matrix mobile Keypad C Program

5/23/2012 3:50 PM

8051 password C Program | Embed4u

13 of 15

http://www.embed4u.com/8051-password-c-program/

Categories: Code Library Tags: 4x4 matrix keypad password c program, 8051 keypad with lcd password c
program|embed4u.com, 8051 password C Program, 8051 password lock c program|embed4u.com, C program for
password-test c program|embed4u.com
Comments (0) Trackbacks (0) Leave a comment Trackback
1. No comments yet.
1. No trackbacks yet.
You must be logged in to post a comment.
GLCD interface with 8051 C code 34 matrix mobile Keypad C Program

5/23/2012 3:50 PM

8051 password C Program | Embed4u

14 of 15

http://www.embed4u.com/8051-password-c-program/

RSS

Recent Posts
stepper motor driver circuit using microcontroller
IR Sensor based visitor counter
mcp3202 interface with 8051
SERVO MOTOR INTERFACE USING PWM
Final Year Embedded IEEE Projects 2010-2011

Categories

5/23/2012 3:50 PM

8051 password C Program | Embed4u

15 of 15

http://www.embed4u.com/8051-password-c-program/

Code Library
DOWNLOAD
Drivers
Electronics
Projects
Related Videos
Schematics
Technology
Tutorial

Blogroll
HEXsource Technologies

Pages
About Us
Contact us
Privacy Policy
Top
Copyright 2009-2011 Embed4u

5/23/2012 3:50 PM

You might also like