8051 password c program _ embed4u

15
Embed4u All About Embedded Hardware and Software Home Code Library DOWNLOAD Drivers Electronics Projects Related Videos Schematics Technology Tutorial 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(); Ads by Google Password Password Program Word Password 8051 8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/ 1 of 15 5/23/2012 3:50 PM

Upload: anil-dsouza

Post on 26-Oct-2014

49 views

Category:

Documents


2 download

DESCRIPTION

door lock password

TRANSCRIPT

Page 1: 8051 Password C Program _ Embed4u

Embed4uAll About Embedded Hardware and Software

HomeCode LibraryDOWNLOADDriversElectronicsProjectsRelated VideosSchematicsTechnologyTutorial

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();

Ads by Google Password Password Program Word Password 8051

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

1 of 15 5/23/2012 3:50 PM

Page 2: 8051 Password C Program _ Embed4u

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=0×96;

while(P1==0×96){}

{

if(P1==0×92)r=0;

if(P1==0×94)r=1;

if(P1==0×86)r=2;

if(P1==0×16)r=3;

get_column();

}

}

void get_column()

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

2 of 15 5/23/2012 3:50 PM

Page 3: 8051 Password C Program _ Embed4u

{

P1=0×68;

while(P1==0×68){}

if(P1==0×48)c=0;

if(P1==0×28)c=1;

if(P1==0×60)c=2;

disp();

delay1();

}

void readp()

{

P1=0×96;

while(P1==0×96){}

{

if(P1==0×92)r=0;

if(P1==0×94)r=1;

if(P1==0×86)r=2;

if(P1==0×16)r=3;

get_columnp();

}

}

void get_columnp()

{

P1=0×68;

while(P1==0×68){}

if(P1==0×48)c=0;

if(P1==0×28)c=1;

if(P1==0×60)c=2;

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

3 of 15 5/23/2012 3:50 PM

Page 4: 8051 Password C Program _ Embed4u

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;

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

4 of 15 5/23/2012 3:50 PM

Page 5: 8051 Password C Program _ Embed4u

}

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()

{

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

5 of 15 5/23/2012 3:50 PM

Page 6: 8051 Password C Program _ Embed4u

int j;

char a[4]={0×38,0×01,0×0e,0×80};

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()

{

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

6 of 15 5/23/2012 3:50 PM

Page 7: 8051 Password C Program _ Embed4u

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()

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

7 of 15 5/23/2012 3:50 PM

Page 8: 8051 Password C Program _ Embed4u

{

display();

}

void init_timer0()

{

dela=3000;

TR0=0;

TMOD=0×01;

IE=0×82;

TH0=0xdc;

TL0=0×00;

TR0=1;

}

void runtimer0()interrupt 1

{

TR0=0;

dela–;

if(dela==3){P1=0×16;}

if(dela==1){P1=0×60;}

if(dela==0){l=0;}

TF0=0;

TH0=0xdc;

TL0=0×00;

TR0=1;

}

void timeopen()

{

l=1;

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

8 of 15 5/23/2012 3:50 PM

Page 9: 8051 Password C Program _ Embed4u

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();

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

9 of 15 5/23/2012 3:50 PM

Page 10: 8051 Password C Program _ Embed4u

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();

}

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

10 of 15 5/23/2012 3:50 PM

Page 11: 8051 Password C Program _ Embed4u

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)

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

11 of 15 5/23/2012 3:50 PM

Page 12: 8051 Password C Program _ Embed4u

{

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:

RTC DS1307 INTERFACE WITH 8051 C PROGRAM1.3×4 matrix mobile Keypad C Program2.

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

12 of 15 5/23/2012 3:50 PM

Page 13: 8051 Password C Program _ Embed4u

Categories: Code Library Tags: 4x4 matrix keypad password c program, 8051 keypad with lcd password cprogram|embed4u.com, 8051 password C Program, 8051 password lock c program|embed4u.com, C program forpassword-test c program|embed4u.comComments (0) Trackbacks (0) Leave a comment Trackback

No comments yet.1.

No trackbacks yet.1.

You must be logged in to post a comment.GLCD interface with 8051 C code 3×4 matrix mobile Keypad C Program

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

13 of 15 5/23/2012 3:50 PM

Page 14: 8051 Password C Program _ Embed4u

RSS

Recent Posts

stepper motor driver circuit using microcontrollerIR Sensor based visitor countermcp3202 interface with 8051SERVO MOTOR INTERFACE USING PWMFinal Year Embedded IEEE Projects 2010-2011

Categories

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

14 of 15 5/23/2012 3:50 PM

Page 15: 8051 Password C Program _ Embed4u

Code LibraryDOWNLOADDriversElectronicsProjectsRelated VideosSchematicsTechnologyTutorial

Blogroll

HEXsource Technologies

Pages

About UsContact usPrivacy Policy

TopCopyright © 2009-2011 Embed4u

8051 password C Program | Embed4u http://www.embed4u.com/8051-password-c-program/

15 of 15 5/23/2012 3:50 PM