Keypad Door Lock using AVR Microcontroller – Atmega16

  • Password Based Keypad Door Lock

 In this article, a digitally secured lock based on password verification is explained. The system uses a seven segment display array to show the password, a matrix keypad to enter the numbers/password and operates a relay (to activate the solenoid valve) for locking and unlocking purpose. The system alarms through a buzzer if a wrong password is entered for 3 times continuously and an SMS is sent to a predefined contact number. The password can be changed whenever required, but only after correctly entering the present password. The password is stored in the EEPROM of the microcontroller so that, power failure or reset of the system does not affect the password recognition.

Keypad Door Lock using AVR Microcontroller – Atmega16

Circuit Diagram

 The system contains a seven segment display array, a 4X4 matrix keypad and a GSM module to send the status message. Based on these requirements, any microcontroller with 3 I/O ports and one UART peripheral is sufficient. In this article ATMEGA16 microcontroller is used. The circuit is developed using the Proteus Simulation software to demonstrate the operation. There is a real-time feature called the ‘Virtual Terminal’ in this software which is used in this article to send the SMS through a GSM Module connected to the computer.

The circuit diagram for connecting the GSM module to the computer is shown below. A detailed explanation on this procedure is provided in the article, “Virtual Comports in Proteus”.

The Matrix Keypad

 In this circuit, a 4X4 matrix keypad is used to enter the password and to interact with the system. A function called the ‘get_key’ function is used to read the pressed key and this key information is passed to the ‘run_key_function’ which is a ‘switch statement’ with 16 cases, and is assigned with one case for each key. As there are 16 keys in the keypad, key value ranges from 1 to 16 and by default, the key value is set out of this range during initialization of the key variable. The ‘get_key’ function refreshes the columns and reads the rows for detecting the pressed key (if any). Whenever a key is pressed this default value is replaced by the currently pressed key. Now, the ‘run_key_function’ is executed and corresponding statements for the pressed key are executed. After execution of these statements, the display function is called until the pressed key is not released. Soon after the key is released, again the key value is set out of range. Below is the program code for the functions ‘get_key’. The ‘get_key’ function can be easily modified for keypads other than the 4X4 matrix.

Keypad Door Lock using AVR Microcontroller – Atmega16 schematics

The Display

 As the password is of four digits, four seven segment LED’s are multiplexed. There is an option to show/hide the password while entering. The display function presented in this article uses one for loop and it can be modified easily if the number of digits is varied. If the show option=1 then digits are shown as they are and if show option=0 then the ‘G’ segment of the displays is enabled instead of the entire digit. The program code for the display function is shown below.

Read more: Keypad Door Lock using AVR Microcontroller – Atmega16


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top