Project report Door lock system (Using AT89C51 Microcontroller) Table of contents 1. DESCRIPTION 2. COMPONENTS 2.1 Potentiometer 2.2 AT89C51 Microcontroller 2.2.1 Pin Description 2.3 16x2 LCD 2.3.1 Pin Description 2.4 4*3 keypad 2.5 ICl293D (Motor driver) 2.5.1 Pin description 3. CIRCUIT DIAGRAM 4. WORKING 5. Code 6. Simulation 1. DESCRIPTION Security is a prime concern in our day-today life. Everyone wants to be as much secure as possible .The issue of security is very paramount at home doors and safe. An access control for doors formsvital.link in a security chain. Therefore we intend to aid in security at home by bringing in an electronic code lock system that involves an individual to enter the password before getting an access to some items, a particular room or building. This code lock system is not just the normal single user code lock system that required a user to insert an already programmed code to gain access to a room or safe; it is a code lock system that has password and enable multiple user access 2Kbytes of ROM for the program memory. The system has a Keypad by which the password can be entered through it. When they entered password equals with the password stored in the memory then the door is opened the microcontroller based Door locker is an access control system that allows only authorized persons to access a restricted area. The system is fully controlled by the 8 bit microcontroller AT89C2051 which has a. If we entered a wrong password for more than three times then the Alarm is switched on. The data pins of LCD are connected to P1 port & RS, R/W, E pins are connected to P0.2, P0.3, and P0.4. L293D is used to rotate motor bidirectional to open & close the locker. A 4*3 keypad is used to enter the numbers 0 to 9 & ‘*’, ‘#’. There is a system menu, contains three buttons for open locker, reset password & close the locker. 2. Components Used 2.1 Potentiometer A preset is a three legged electronic component which can be made to offer varying resistance in a circuit. The resistance is varied by adjusting the rotary control over it. The adjustment can be done by using a small screw driver or a similar tool. The resistance does not vary linearly but rather varies in exponential or logarithmic manner. Such variable resistors are commonly used for adjusting sensitivity along with a sensor. The variable resistance is obtained across the single terminal at front and one of the two other terminals. The two legs at back offer fixed resistance which is divided by the front leg. So whenever only the back terminals are used, a preset acts as a fixed resistor. Presets are specified by their fixed value resistance. 2.2 Micro Controller AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (PEROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times. In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually. Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts. 2.2.1Pin Configuration: 2.3 LCD (Liquid Crystal Display): LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments and other multi segment LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on.A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command and Data. The command register stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor position, controlling display etc. The data register stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD. 2.3.1 Pin Description: This is the pin configuration of 16x2 LCD. One port of micro controller is connected to lcd pin 3-10 for data sending. While pin 11 is enable pin and pin 12 is connected to microcontroller pin 26. On pin 15 we have to supply vcc supply and we have to ground pin 16 2.4 4*3 keypad: A 4*3 keypad is used to take input from user. The password is entered through keypad. 2.5 IC L293D(Motor driver): IC L293D is used to drive a motor since microcontroller can provide current up to certain limit which is not enough in some cases as in our case microcontroller cannot provide enough current to drive the motor so we have to use this to drive our motor. 2.5.1 Pin description: Pin description of the ic is given as. 3. Circuit diagram: 4. WORKING: . The system has a Keypad by which the password can be entered through it. When the entered password equals with the password stored in the memory then the door is opened the microcontroller based Door locker is an access control system that allows only authorized persons to access a restricted area. The system is fully controlled by the 8 bit microcontroller AT89C2051 which has a. If we entered a wrong password for more than three times then the Alarm is switched on. The data pins of LCD are connected to P1 port & RS,R/W,E pins are connected to P0.2,P0.3,P0.4. L293D is used to rotate motor bidirectional to open & close the locker. A 4*3 keypad is used to enter the numbers 0 to 9 & ‘*’, ‘#’. There is a system menu, contains three buttons for open locker, reset password & close the locker The password can be reset and after changing the password the system will work according to new password. There is a button to close the door lock system also. There is beep that will on if wrong password is entered twice. 5. Code: PROJECT CODE #include< reg51.h > #define col P2 #define row P3 sbit m1=P3^4; sbit m2=P3^5; sbit bu=P0^1; sbit rs=P0^2; sbit rw=P0^3; sbit en=P0^4; sbit start=P0^5; sbit rst=P0^6; sbit mp=P0^7; sfr lcddata=0×90; void delay(int a) { int i,j; for(i=0;i<a;i++) for(j=0;j<1100;j++); }</a;i++) Void command (unsigned char s) //initialize of the LCD { lcddata=s; rs=0; rw=0; en=1; delay(5); en=0; } void lcddisplaydata(unsigned char s) //Data writing of the Lcd { lcddata=s; rs=1; rw=0; en=1; delay(8); en=0; } void displaydata(unsigned char *word) { int x; for(x=0;word[x]!=0;x++) //Data writing of the LCD { lcddisplaydata(word[x]); } } unsigned char array[3][4]={’0′,’1′,’2′,’3′, ’4′,’5′,’6′,’7′, ’8′,’9′,’*',’#'}; int n=0; int m=0; int i,p,q,r; void main() { unsigned char colloc, rowloc; unsigned char array1[4]; unsigned char array2[4]={’3′,’1′,’1′,’2′}; unsigned char array3[4]; LOCKER1: col=0xFF; row=0×00; m1=0; m2=0; bu=0; mp=1; p=0; q=0; r=0; m=0; start=1; rst=1; command(0×01); command(0×38); command(0x0C); command(0×84); displaydata(“PRESS KEY”); command(0xC0); displaydata(“FROM SYSTEM MENU”); while(1) { if(start==0) { p=1; goto LOCKER2; } else if(rst==0) { q=1; goto LOCKER3; } } LOCKER2: n=0; command(0×01); command(0×82); delay(10); displaydata(“Enter Your”); command(0xC3); displaydata(“Password”); delay(80); command(0×01); command(0×80); goto LOCKER5; LOCKER3: n=0; command(0×01); command(0×82); delay(10); displaydata(“Enter Current”); command(0xC4); displaydata(“Password”); delay(80); command(0×01); command(0×80); goto LOCKER5; LOCKER4: n=0; m=0; command(0×01); command(0×83); delay(10); displaydata(“Enter new”); command(0xC3); displaydata(” Password”); delay(80); command(0×01); command(0×80); q=2; goto LOCKER5; LOCKER5: col=0xFF; while(1) { do { row=0×00; colloc=col; colloc &=0x0f; }while(colloc!=0x0f); do { colloc=col; colloc &=0x0f; }while(colloc==0x0f); while(1) { row=0x0E; colloc=col; colloc &=0x0f; if(colloc!=0x0f) { rowloc=0; break; } row=0x0D; colloc=col; colloc &=0x0f; if(colloc!=0x0f) { rowloc=1; break; } row=0x0LOCKER11; colloc=col; colloc &=0x0f; if(colloc!=0x0f) { rowloc=2; break; } } if(p==1) { if(colloc==0x0E) { array1[n]=array[rowloc][0]; n++; goto LOCKER6; } else if(colloc==0x0D) { array1[n]=array[rowloc][1]; n++; goto LOCKER6; } else if(colloc==0x0B) { array1[n]=array[rowloc][2]; n++; goto LOCKER6; } else if(colloc==0×07) { array1[n]=array[rowloc][3]; n++; goto LOCKER6; } } else if(q==1) { if(colloc==0x0E) { array1[n]=array[rowloc][0]; n++; goto LOCKER7; } else if(colloc==0x0D) { array1[n]=array[rowloc][1]; n++; goto LOCKER7; } else if(colloc==0x0B) { array1[n]=array[rowloc][2]; n++; goto LOCKER7; } else if(colloc==0×07) { array1[n]=array[rowloc][3]; n++; goto LOCKER7; } } else if(r==2) { if(colloc==0x0E) { array1[n]=array[rowloc][0]; n++; goto LOCKER11; } else if(colloc==0x0D) { array1[n]=array[rowloc][1]; n++; goto LOCKER11; } else if(colloc==0x0B) { array1[n]=array[rowloc][2]; n++; goto LOCKER11; } else if(colloc==0×07) { array1[n]=array[rowloc][3]; n++; goto LOCKER11; } } else if(q==2) { if(colloc==0x0E) { array2[n]=array[rowloc][0]; n++; goto LOCKER9; } else if(colloc==0x0D) { array2[n]=array[rowloc][1]; n++; goto LOCKER9; } else if(colloc==0x0B) { array2[n]=array[rowloc][2]; n++; goto LOCKER9; } else if(colloc==0×07) { array2[n]=array[rowloc][3]; n++; goto LOCKER9; } } else if(q==3) { if(colloc==0x0E) { array3[n]=array[rowloc][0]; n++; goto LOCKER8; } else if(colloc==0x0D) { array3[n]=array[rowloc][1]; n++; goto LOCKER8; } else if(colloc==0x0B) { array3[n]=array[rowloc][2]; n++; goto LOCKER8; } else if(colloc==0×07) { array3[n]=array[rowloc][3]; n++; goto LOCKER8; } } } LOCKER6: if(n<4) { lcddisplaydata(‘*’); goto LOCKER5; } else if(n==4) { lcddisplaydata(‘*’); delay(50); if(array1[1]==array2[1]&&array1[2]==array2[2]&&array1[3]==array2 [3]&&array1[0]==array2[0]) { command(0×01); command(0×80); displaydata(“RIGHT PASSWORD”); delay(50); m=0; n=0; goto LOCKER14; } else { command(0×01); command(0×80); displaydata(“WRONG PASSWORD”); delay(50); goto LOCKER15; } } LOCKER7: if(n<4) { lcddisplaydata(‘*’); goto LOCKER5; } else if(n==4) { lcddisplaydata(‘*’); delay(50); if(array1[1]==array2[1]&&array1[2]==array2[2]&&array1[3]==array2 [3]&&array1[0]==array2[0]) { goto LOCKER4; } else { goto LOCKER12; } } LOCKER8: if(n<4) { lcddisplaydata(‘*’); goto LOCKER5; } else if(n==4) { lcddisplaydata(‘*’); delay(50); if(array3[1]==array2[1]&&array3[2]==array2[2]&&array3[3]==array2 [3]&&array3[0]==array2[0]) { command(0×01); command(0×80); delay(10); displaydata(“New Password has”); command(0xC3); displaydata(“been set”); delay(100); command(0×01); m=0; goto LOCKER1; } else { goto LOCKER13; } } LOCKER9: if(n<4) { lcddisplaydata(‘*’); goto LOCKER5; } else if(n==4) { lcddisplaydata(‘*’); delay(50); m=0; goto LOCKER10; } LOCKER10: { command(0×01); command(0×80); delay(10); displaydata(“Conform Password”); delay(50); command(0×01); q=3; n=0; goto LOCKER5; } LOCKER11: if(n<4) { lcddisplaydata(‘*’); goto LOCKER5; } else if(n==4) { lcddisplaydata(‘*’); delay(50); if(array1[1]==array2[1]&&array1[2]==array2[2]&&array1[3]==array2 [3]&&array1[0]==array2[0]) { bu=0; goto LOCKER1; } else { goto LOCKER16; } } LOCKER12: { command(0×01); command(0×80); m++; if(m<3) goto LOCKER3; else bu=1; delay(500); bu=0; goto LOCKER1; } LOCKER13: { command(0×01); command(0×80); m++; if(m<3) goto LOCKER10; else goto LOCKER1; } LOCKER14: { m1=1; m2=0; delay(125); m1=0; m2=0; while(mp!=0); m1=0; m2=1; delay(125); m1=0; m2=0; delay(100); command(0×01); command(0×80); goto LOCKER1; } LOCKER15: { command(0×01); command(0×80); m++; if(m<3) goto LOCKER2; else bu=1; r=2; p=0; q=0; n=0; goto LOCKER5; } LOCKER16: { command(0×01); command(0×80); n=0; goto LOCKER5; } } 6. Simulation: Our project worked properly in simulation Didderent steps of simulation
© Copyright 2024