Electronic lock using pic microcontroller

Electronic lock using pic microcontroller and keypad. In this article, you will learn how to design electronic lock using pic16f877a microcontroller based embedded system? What are its applications? How to write its program? How to use it in any project? It is very useful for mechatronics engineering students.

What is a microcontroller based electronic lock?

This project used a password to open any lock. It can be used to make any device password protected. For example, speed control of a dc motor, home automation system, automatic doors, and Measurements systems can be made password protected, the electronic bell of school can also be made password protected using the electronic lock. So you can use microcontroller based electronic lock to make any device password protected. While working on microcontrollers based embedded system project, you may come across situation where you want an electronic device to protect from random users inputs. In such situation, you can use electronics lock. You must be wondering what is microcontroller based embedded system? Actually two types of embedded systems are used now a days; microcontroller based embedded systems and Linux-based embedded systems. But  the explanation of these topics is beyond the scope of this article. I will try to write a separate article on it.

Working of Electronic lock

circuit diagram of electronics lock is shown below. Electronic lock takes inputs from the user with the help of 4X4 keypad. PIC16F877A microcontroller reads these inputs and compared it with a already stored password. Default password 1234 is stored in EEPROM of PIC microcontroller. After taking inputs from a user, these inputs are stored in array. After that microcontroller compares these arrays values with already stored valued of a default password. If both the values are equal microcontroller opens the electronic lock. Liquid crystal display is interfaced with PIC16F877A. LCD is used to display the status of password protected secured system. If user input password is equal to EEPROM stored password. Status of “access has been granted” Displayed on LCD. PIC provides instructions to LCD about what to display and what not to display. Use of LCD is optional. It is not necessary to use it. You can use a light emitting diode to display status of electronic lock. For example LED remains off when lock is closed and LED remains on when lock is open. So it’s up to you whatever you want to use. For example in home devices control system project, you can use password to provide access to control of devices to only specific persons.

Components used in Electronic lock

Followings are the list of components used in while it’s designing.

  • PIC16F877A controller: It is main part of this project. You can say it is heart of this system. Because it controls all the functions. It takes inputs from user with the help of keypad. It compares the already stored password in EEPROM with entered inputs. It also provides instructions to LCD to display status. So to design such system you should have knowledge of microcontrollers. If you don’t know, I recommend you to check this article: Getting started with PIC microcontrollers
  • Liquid crystal display: It displays the status of password secured system. It also shows either access has been granted or not. I have already explained above how LCD is being controlled. If you don’t know how to use LCD, you can read this article: LCD interfacing with PIC16877A
  • 4×3 Keypad: It consists of 12 push buttons. It has four rows and three columns. Specific number is given to each button. Microcontroller doesn’t know which button has assigned which value. So we have to tell controller through programming about which value is assigned to which button. There are many types of keypads available in market. You can use anyone according to your requirement. To know more about it and its use, I suggest you to read this article: Keypad interfacing with PIC16F877A
  • Crystal oscillator: Eight mega hertz crystal oscillator is used in this project. Two 22pF capacitors are connected with it. Crystal oscillator decides the operating frequency of the system.

I can say with 100 percent confident that after learning a use of above-mentioned components, you will be able to design intelligent lock very easily.

Circuit diagram of electronics lock

It’s complete circuit diagram is shown below. As you can see all the components which I have explained above is used. There is only one extra component that is LED. LED is connected just as an option. It will turn on when locker is open and it will remain turn off otherwise.

Electronic lock using pic microcontrollers-min

I think, I have already explained each and everything of this circuit above. Nothing is left to explain. But I have also included a video lecture below. In video lecture, I have explained circuit in more details. I have also shown its real time working. I also provide details of programming in this video. Subscribe my channels on YouTube or daily motion for more video tutorials.

Program of electronic lock

Code is written using c language, because, it is easy to write code in c language. Also it is less time consuming. One of the main feature of c language is that it is portable means c code written for one microcontroller of microchip can be used for others also by making little bit changes. But in case of assembly language, one have to write complete code again and assembly code takes too much time and it is very tedious. I have tried my level best to provide you complete guide on electronic lock through this article and video tutorial. I hope you can able to write c code yourself after reading this article. But if you need code, you can contact me on my email address: microcontrollerslabhub@gmail.com. Note: contact me only, if you want to purchase code. It is not free of cost. Thanks J

9 thoughts on “Electronic lock using pic microcontroller”

  1. please, i will be grateful to sent the ‘source code and circuit diagram’ for the above project topic(solar baesd aumatic irrigation system)

  2. Hello Malik, thanks for all your help put on web.
    Please can your help me, i want to make an ac voltmeter (0-230v) and an ammeter (0-60A).
    i saw votmeter and ammeter that you have post but how can i adapt it to what i want to do.
    Can you help me please.

  3. hey Dr. Malik ,
    thanks for all your help,
    please can you give me the code and the flow chart of (electronic lock using pic microcontroller ).

    thanks in advance.

  4. i need coding of this electronic lock …. bcz i am doing my final year project based on pic microcontroller.. above video is very usefull for our project so i want that coading for doing my project coading…. please sent that coading on my mail…. thank you

    • hey Dr. Malik ,
      thanks for all your help,
      please can you give me the code and the flow chart of (electronic lock using pic microcontroller ).

      thanks in advance.


Leave a Comment