Spread the love

password based door locking system with 8051



Traditional lock systems using mechanical lock and key mechanism are being replaced by new advanced techniques of locking system. These techniques are an integration of mechanical and electronic devices and highly intelligent. One of the prominent features of these innovative lock systems is their simplicity and high efficiency.  Such an automatic lock system consists of electronic control assembly which controls the output load through a password. This output load can be a motor or a lamp or any other mechanical/electrical load.

Principle Behind the Project:

The main component in the circuit is 8051 controller. In this project 4×3 keypad is used to enter the password. The password which is entered is compared with the predefined password. If the entered password is correct then the system opens the door by rotating door motor and displays the status of door on LCD. If the password is wrong then door is remain closed and displays “ wrong Password access denied” on LCD.

Working of Password Based Door Locking System with 8051

When power supply is turned on a message “Enter Your Password ” is displayed on LCD. We type the password using keypad which is attached with the system. If password does not match door remains closed and a message “wrong Password access denied ”  is displayed on LCD. If password matched then a message “Password matched access granted ” is displayed on the LCD and motor rotates and door opened ,after some time door closed.

Application and Advantage: 

  • Can be used in various rooms like seminar hall, conference room, and study rooms in college .
  • The project (password detector) can be used to automate the door locking process, so the user need not to carry the door lock keys along with him, he can just remember the password and use it later to open the door.
  • This project provides security.
  • Power consumption is less.
  • Used commonly available components.
  • Project is simple and easy

1. Circuit Diagram of Password Based Door Locking System with 8051

circuit diagram of Password Based Door Locking System with 8051

1. Program of Password Based Door Locking System with 8051

#include<reg51.h>

#include"delay.h"
#include"lcd.h"
#include"keypad.h"
/******************
motor PIN
******************/
sbit a1=P2^0;
sbit a2=P2^1;
sbit a3=P2^2;
sbit a4=P2^3;

void motor();

unsigned char ar[5];

unsigned char com[5]={"77777"};

unsigned int f,m=1,p;

/******************
main program
******************/
void main()
{
	unsigned int i;
		
	lcd_ini();
		
	while(1)
	{
		cmd(0x01);
		lcd_str(" ENTER YOUR");
		cmd(0xc0);
		lcd_str(" PASSWORD");

		for(i=0;i<5;i++)
		{
			keypad1();
			
			ar[i]=c;
			
			if(i==0)
			{
			  cmd(0x01);
				lcd_display(' ');
			}
			lcd_display('*');
		}

			//compare();
		if(ar[0]==com[0] && ar[1]==com[1] && ar[2]==com[2] && ar[3]==com[3] && ar[4]==com[4])
		{
			m=1;
		}
		else
		{
			m=0;
		}
		if(m==1)
		{
			cmd(0x01);
			lcd_str(" PASSWORD MATCHED");
			cmd(0xc0);
			lcd_str(" ACCESS GRANTED");
			
			motor();
			p=0;
			delay_fv(1000,100);
		}
		else if(m==0)
		{
			p++;
			cmd(0x01);
			lcd_str(" WRONG PASSWORD");
			cmd(0xc0);
			lcd_str(" ACCESS DENIED");
			delay_fv(1000,100);
			delay_fv(1000,100);
			m=1;
			if(p==3)
			{
					cmd(0x01);
					lcd_str(" PLEASE CONTACT");
					cmd(0xc0);
					lcd_str(" YOUR HOD....");
					while(p==3);
			}
		}
	}
}



void motor()
{ 
	unsigned int i;
	
	for(i=0;i<10;i++)
	{
		a2=a3=a4=0;
		a1=1;
		delay_ff();
		a1=a3=a4=0;
		a2=1;
		delay_ff();
		a1=a2=a4=0;
		a3=1;
		delay_ff();
		a1=a2=a3=0;
		a4=1;
		delay_ff();
  }
	delay_fv(1000,100);
	for(i=0;i<10;i++)
	{
		a2=a3=a1=0;
		a4=1;
		delay_ff();
		a1=a2=a4=0;
		a3=1;
		delay_ff();
		a1=a3=a4=0;
		a2=1;
		delay_ff();
		a4=a2=a3=0;
		a1=1;
		delay_ff();
	}
}

lcd.h

sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
sfr lcd=0x90;

void lcd_display(unsigned int x)  // lcd display fuction
{
	unsigned int i;
	lcd=x;
	rs=1;
	rw=0;
	en=1;
	for(i=0;i<100;i++);
	en=0;
 
}
 
void cmd(unsigned char m)  // lcd command fuction
{
	unsigned int i;
	lcd=m;
	rs=0;
	rw=0;
	en=1;
	for(i=0;i<10;i++);
	en=0;
}
 
void lcd_ini()   // lcd initilize
{
	cmd(0x38);
	cmd(0x0e);
	cmd(0x01);
	cmd(0x06);
	cmd(0x90);
}	
void lcd_str(unsigned char *str)   // display string on lcd
{
	while(*str!='\0')  
	{
	  lcd_display(*str);
	  str++;
	}
}

keypad.h

sbit r1=P0^0; // row 1
sbit r2=P0^1; // row 2
sbit r3=P0^2; // row 3
sbit r4=P0^3; // row 4
sbit c1=P0^4; // column 1
sbit c2=P0^5; // column 2
sbit c3=P0^6; // column 3
sbit c4=P0^7; // column 4

unsigned int c;

char keypad1()
{	
	P2=0xff;
	while(1)
	{
		r1=0;
		r4=1;
		if(c1==0)
		{
			c='7';
			delay_pf(500);
			return c;
		}
		else if(c2==0)
		{
			c='8';
			delay_pf(500);
			return c;
		}
		else if(c3==0)
		{
			c='9';
			delay_pf(500);
			return c;
		}
		else if(c4==0)
		{
			c='/';
			delay_pf(500);
			return c;
		}

		r1=1;
		r2=0;
		if(c1==0)
		{
			c='4';
			delay_pf(500);
			return c;
		}
		else if(c2==0)
		{

			c='5';
			delay_pf(500);
			return c;
		}
		else if(c3==0)
		{
			c='6';
			delay_pf(500);
			return c;
		}
		else if(c4==0)
		{
			c='*';
			delay_pf(500);
			return c;
		}

		r2=1;
		r3=0;
		if(c1==0)
		{
			c='1';
			delay_pf(500);
			return c;
		}
		else if(c2==0)
		{

			c='2';
			delay_pf(500);
			return c;
		}
		else if(c3==0)
		{
			c='3';
			delay_pf(500);
			return c;
		}
		else if(c4==0)
		{
			c='-';
			delay_pf(500);
			return c;
		}
		
		r3=1;
		r4=0;
		if(c1==0)
		{
			delay_pf(500);
			cmd(0x01);
		}
		else if(c2==0)
		{

			c='0';
			delay_pf(500);
			return c;
		}
		else if(c3==0)
		{
			c='=';
			delay_pf(500);
			return c;
		}
		else if(c4==0)
		{
			c='+';
			delay_pf(500);
			return c;
		}
	}
}

delay.h

void delay_ff()  // fully fixed delay
{
    unsigned int i,j;
	
    for(i=0;i<80;i++)
    for(j=0;j<120;j++);
}

void delay_pf(unsigned int x)  // partial variable delay
{
	unsigned int i,j;
	
	for(i=0;i<x;i++)
	for(j=0;j<50;j++);
}

void delay_fv(unsigned int x,y)  // fully variable delay
{
	unsigned int i,j;
		
	for(i=0;i<x;i++)
	for(j=0;j<y;j++);
}

PROTEUS File for SIMULATION(Password Of RAR file is :-firmcodes.com)

download (1)

Coming soon….