Password based door lock system

Published Jul 25, 2020
 4 hours to build
 Beginner

This project is a password based electronic code lock designed using the 8051 micro controller. The system includes an electronic control assembly that controls the output load via a numerical password . Once the correct code or password has been entered, the door opens and the person is allowed to enter. If the password is incorrect, the door will be locked, denying access to the person.

display image

Components Used

LCD16x2 Display
LCD16x2 Display
1
Breadboard
Breadboard
1
8051 AT89c51
8051 AT89c51
1
L293D Driver
L293D Driver
1
26MHz Crystal
Crystals 26MHz 13pF -20C 70C
1
Resistor 1 kOhms
Metal Film Resistors - Through Hole 1K ohm 1/4W 1%
1
DC Gearbox Motor
Adafruit Accessories DC Gearbox Motor - TT Motor - 200RPM - 3 to 6VDC
1
Potentiometer 10Kohms
Potentiometers 10Kohms 10% 12.5mm Cermet Element
1
Description

PRINCIPLE OF OPERATION

The major components of the system are an AT89S52 microcontroller, Keypad module, DC motor, and LCD Display. The AT89S52 microcontroller controls all processes including accepting the password from the Keypad module, comparing it to the key, driving the dc motor, and sending status to LCD. The keypad is used as the input interface for inserting a password into the microcontroller. Based on the password entered the motor driver controls the dc motor for opening/closing the lock and LCD act as the display for the keypad as well as showing status messages. 

DESIGN AND IMPLEMENTATION

Oscillator Circuit Design: An 11.0592MHz crystal oscillator is used to provide an external clock signal to the microcontroller. To ensure smooth operation, connected two 22pF ceramic capacitors. This crystal oscillator is connected between pin 18 and 19 of the microcontroller.

Interfacing LCD and Keypad: First, a 1KΩ Potentiometer is connected to the LCD Display’s Contrast Adjust Pin (Pin 3). The LCD control pins RS, RW, and E are connected to P2.0, GND and P2.1 pins respectively. The eight data lines of the LCD are connected to PORT1. The four ROW pins of the Keypad are connected to P3.0 to P3.3 and the four COLUMN pins of the Keypad are connected to P3.4 to P3.7 pins respectively.

Interfacing Motor Driver: The IN1 and IN2 of the L293D Motor Driver are connected to P2.2 and P2.3. The motor is connected between OUT1 and OUT2 pins of L293D.

ASSEMBLY CODE 

We used the Keil µVision software to write the program in assembly language and generate the hex file. For the circuit simulation, we use the Proteus software and the hex file is uploaded to the microcontroller. Basic logic flow is as follows:

The program first initializes all components and data pointers, then waits for the user to input characters. According to the character entered, the corresponding function is invoked and it is stored to the memory as well as displayed. Once 4 characters have been entered, it is compared to the password saved in the memory earlier. If each character matches it goes on to call the success function, otherwise the failure function. Those functions execute their activity and after those, the flow returns to the start and awaits the user until used next time. 

WORKING OF THE SYSTEM 

When we switch on the system will display a message on the LCD screen - “Enter the password”. The user then has to input 4 characters into the keypad. Once 4 digits are entered, the system will check the password (by comparing the input 4 digits with the stored password-1234). The password is checked digit by digit.

If the password entered is matched, a message will be displayed on the LCD screen- “Success”. The microcontroller makes P2.2 LOW and P2.3 HIGH, so the motor driver gets the input signals for the forward motion of the motor. As a result, Door Motor rotates in a forward direction to open the door. After a delay, the microcontroller makes P2.2 LOW and P2.3 LOW, so the motor driver gets the input signals for reverse motion. As a result, the Door motor rotates in the reverse direction to close the door.

If the password entered is wrong, a message “Failed” will be displayed on the LCD screen. The microcontroller maintains both P2.2 and P2.3 LOW. Hence, the door motor is stationary so that door remains closed.

PROTEUS SIMULATION RESULTS 

When we run the simulation the LCD display a message “Enter the password” and wait for the input from the user through the keypad

  1. When the wrong password is entered;

LCD displays a message - “Failure” and the DC motor remains stationary. After a period of delay the system returns to the initial state with LCD display showing “Enter the password” 

  1. When the correct password is entered;

LCD displays a message-” Success” and the motor driver will drive the dc motor in an anti-clockwise direction (implies the opening of the door). After a period of delay (the door remains opened) the dc motor rotates in the clockwise direction (implies the closing of the door)

After this process of opening and closing, the system returns to the initial state of receiving the password from the user. 

Codes

Downloads

Simulation Download
Simulation Results images Download
Comments
Ad