-->

Micro controller Based Password Lock

By

Password based Door locking system

This is a  8051 based security project, we can lock and unlock the door electronically. Electronic door locking systems are used in Bank lockers, home lockers, main doors and prison  etc.,

Working: When we give correct UserID and Password then only we can UNLOCK and LOCK the door otherwise we can't operate it. If we entered correct userID and password it will show authenticated message on LCD screen otherwise Invalid userID or Access Denide. Then you can select one of the option LOCK DOOR and UNLOCK DOOR.
Here is the functional flow chart 
Here we are showing how door can be locked and unlocked mechanically and electrically with mechanical body of the door     
case'1': when the door is locked    


case'2':When the door is unlocked
















NOTEI haven't connected any motor driver here, but practically we can interconnect opto-coupler or motor driver H-bridge

Code


// Password based Door lock 
// modifying userID and Password
#include
sfr ROW=0x80;	//assigning PORT-0 to read rows
sfr COL=0xA0;	//assigning PORT-2 to read colomns
sfr ldata=0x90;	//assigning PORT-1 for LCD data
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
sbit busy=P1^7;
sbit servo=P3^3;          //Output to motor
void lcdcmd(unsigned char value) ;
void lcddata(unsigned char value);
void lcdready(void)	   ;
void printstring(unsigned char ch[]) ;
void LCDclear(void);
void msdelay(unsigned int value)  ;
int keypad();
void timer(unsigned int msec);
void door_open(void);

void door_close(void);
unsigned char userID[5]={"9876"};
unsigned char password[5]={"1234"};
unsigned char update_1[5]={"0000"};
 unsigned char update_2[5]={"0000"};
 unsigned char x;
void main(void)
{ 
 unsigned int i,k;
 
 
  lcdcmd(0x38);
  lcdcmd(0x0F);
  lcdcmd(0x06);
  lcdcmd(0x01);
  //while(1){
  LCDclear();
  lcdcmd(0x80);
  while(1)
  {
  printstring("userID:");
  lcdcmd(0x87);
  
   i=0;
  do
  {
   update_1[i]=keypad();
   lcddata(update_1[i]);
   i++;
   }while(i!=4);
   i=0;
   if(update_1[0]==userID[0] && update_1[1]==userID[1] && update_1[2]==userID[2] && update_1[3]==userID[3] )
   {
 		 lcdcmd(0xC0);
 		 printstring("password:");
  		 lcdcmd(0xC9);
  
 		 do
 		 {
  			 update_1[i]=keypad();
  			 i++;
  			 lcddata('*');
  		 }while(i!=4);
		  if(update_1[0]==password[0] && update_1[1]==password[1] && update_1[2]==password[2] && update_1[3]==password[3] )
 		   {
		   LCDclear();
		   printstring("Authenticated");
		   msdelay(2000);
		   LCDclear();
		   lcdcmd(0x80);
		   printstring("1.Unlock Door");
		   lcdcmd(0xC0);
		   printstring("2.lock Door");

		   do
		   {
		    k=keypad();
			}while(k!='1' && k!='2' && k!='C');
		    switch(k)
			{
			 case '1' :while(1)
						 { 
						 door_open();
						if('2'==keypad())
						   door_close();
			 			if('C' ==keypad())
				 			{
				 				main();
							}	
						}
			 			break;
			case '2' : 	while(1)
						{
						 door_close();
						 if('1'==keypad())
						 door_open();
						if('C' ==keypad())
						 {
				 			main();
					    	}
						}
						break;
			case 'C' : main();
						break;
			default  :main();
					  break;
			}
		   }

		   else
		   {
		   LCDclear();
		   printstring("Access Denide");
		   msdelay(1000);
		   LCDclear();
		  
		   main();
		   }
 	
 }
 else
 {
  LCDclear();
  printstring("Invalid UserID");
  msdelay(1000);
  main();  		   
 }
 }
 }
 /* sending commands to  LCD display to act in command mode */ 
void lcdcmd(unsigned char value)
{
 lcdready();
 ldata=value;
 rs=0;
 rw=0;
 en=1;
 msdelay(10);
 en=0;
 }
 /* sending commnad to LCD to display characters*/
void lcddata(unsigned char value)
{
 lcdready();
 ldata=value;
 rs=1;
 rw=0;
 en=1;
 msdelay(10);
 en=0;
 }
 /* checking LCD buffer for free */
void lcdready(void)
{
 busy=1;
 rs=0;
 rw=1;
 if(busy==1)
  {
   en=0;
   msdelay(1);
   en=1;
   }
}

void printstring(unsigned char ch[])
{
 unsigned int i;
 for(i=0;ch[i]!='\0';i++)
 lcddata(ch[i]);
 }
/* generating delay*/
void msdelay(unsigned int value)
{
 unsigned int i,j;
 for(i=0;i




More Posts

gElectron. Powered by Blogger.

Contributors

16x2 LCD Interfacing with STM32,STM32F103C6

 16x2 LCD  Interfacing with STM32,STM32F103C6 lcd_init(); LCD_LINE1; lcd_String(" GeElectron"); LCD_LINE2; lc...

Contact Form

Name

Email *

Message *

Contact us

Name

Email *

Message *

Follow Us

https://www.facebook.com/gElectron-393939667321867/ FBbox/https://www.facebook.com/IVYthemes

Comments

[blogger]

MKRdezign

Test
google.com, pub-8429441124104529, DIRECT, f08c47fec0942fa0
[blogger]

Latest

[recent][newsticker]

Technology

Top Ads

RECENT COMMENTS

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)


Your email address is safe with us!

RECENT COMMENTS