Embedded Projects Blog: PIC Microcontroller Based Electronic Lock

PIC Microcontroller Based Electronic Lock

 Circuit Diagram

Security is a prime concern in our day-today life. Everyone wants to be as much secure as possible. An access control for doors forms a vital link in a security chain. The microcontroller based digital lock for Doors is an access control system that allows only authorized persons to access a restricted area.
An electronic lock or digital lock is a device which has an electronic control assembly attached to it. They are provided with an access control system. This system allows the user to unlock the device with a password. The password is entered by making use of a keypad. The user can also set his password to ensure better protection. The major components include a Keypad, LCD and the controller PIC16F877A. This article describes the making of an electronic code lock using the 16F877A microcontroller.

The system is fully controlled by the 8 bit microcontroller 16F877A which has a 8Kbytes of ROM for the program memory. The password is stored in the EPROM so that we can change it at any time. 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 relay gets on and so that the door is opened.

The code is built in a modular style to allow a user to find ways to modify  project. In start the D Lock programs loads with a default code of "2345" format is *2345# which can be enter to unlock the door, the code cam be change by entering the master code in the format *23455#new 4 digit code.  In this program i only display the result on LCD and lock will be  placed at   PORTA bit 0 where i put led for simulation. 



A 4x3 matrix keypad and a 16x2 LCD have been used here. Keypad and LCD are very commonly used input & output devices, respectively. The password is stored in the system EEPROM.
While unlocking, if the entered password from keypad matches with the stored password, then the lock opens and a message is displayed on LCD. Also an output pin is made high to be used for further purpose..

As the program starts, wait for 5sec and press * string ‘Enter Password’ is displayed on LCD. The keypad is scanned for pressed digits one by one. Every time, row and column of the key pressed is detected and is displayed on LCD. After the four digits are entered, the user should press # to Confirm Password and again the input is taken through LCD. If the passwords do not match, a message is displayed to indicate ‘Access Denied’ otherwise the ‘Access Granted’ message.

The default password is 2345 and master key to change password is 23455., entry begins with * and stops with #.

Update 28-8-2013

 1. Here two circuit are provided, the smaller one works only for 

simulation and the larger one works only    in real world( Problem

with Pull Down resistors)

2. Due to frequent Requests I have Uploaded the HEX(8Mhz Crystal) file of these project in Our Facebook Group-Click Here

Code 

 

  Discussion Group




Facebook Page                                                                                                                  Contents Page

 


Check Our New Blog: Embedded Projects-Tutorials-Arduino-Android-Raspberry PI- Gadgets News - Embedded Hackes - New Embedded Products Intro etc 

 (click the Image Below to Visit the Blog)

www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CCoQFjAA&url=http%3A%2F%2Farrogancegizmo.blogspot.com%2F&ei=SMaRUsGzCYj_rAfA-4GoDw&usg=AFQjCNEw6Pm6VepdEnZlm1evPy5f0N2NdA&sig2=sG5PkXDQilaUfIan6u2Wzw&bvm=bv.56988011,d.bmk
 

67 comments:

  1. Password should not be displayed on LCD. It is not secured. **** can be displayed instead.

    ReplyDelete
    Replies
    1. Thank you foe your advise. This project is designed as an academic project. Simplicity is for the ease of demonstration. And added a buzzer and some more features to it. If anybody enter wrong password more than three times, the buzzer sounds continuously and system should be restarted.

      Delete
    2. Sir can u email me about circuit with buzzer. And about the code can u email me assemby programming not c programming. Sitihafizah9491@gmail.com

      Delete
  2. i have a problem. i designed a system using this code. but it cant simulate in real simulation

    ReplyDelete
  3. @Nayantha
    Its working no problem. I will send the whole project in proteus. You should use pull downs for all pins connected to keypad in a real design.

    ReplyDelete
    Replies
    1. nupsangel05@gmail.com
      really interested to kjnow the deatails of this project..so pls send me here..

      Delete
  4. thanks for this great idea
    but i need this programs in Mikrobasic can you get it for me??

    ReplyDelete
  5. is the code given full complete..?

    ReplyDelete
  6. if you like everything related to micro-controllers visit my blog:

    All about Embedded Systems

    ReplyDelete
  7. can u pls send me the whole project in proteus? because it is my project now and i have a problem about the circuit. I don't know where do i put the oscillator, the resistor in keypad and its value? and where do i put the L7805 5V output to pic? I hope you send it to me immediately because the deadline of my project is on OCT.12(Friday). thank you for your electronic lock =)

    ReplyDelete
    Replies
    1. @ Raimar : Please check this link
      http://www.facebook.com/photo.php?fbid=367276126688130&set=a.258302774252133.62236.258274150921662&type=1&relevant_count=1

      Delete
  8. THANK YOU FOR THIS SUCH A GOOD COMPILATION OF PROJECTS. CAN YOU MAIL ME. THIS PROJECT CODING ON NOTEPAD.

    MY EMAIL ADDRESS IS

    cheez.wheelz@gmail.com

    ReplyDelete
  9. THANK YOU FOR YOUR QUICK REPLY. IF I WANT TO USE 4X4 KEYPAD WHAT CHANGES ARE EXPECTED.

    ReplyDelete
    Replies
    1. connect the 4th column to 4th(1,2,3,4) pin of the keypad port, and make required change in program.

      Delete
  10. greeting

    i am having a problem while compiling this code at mikroc version 8.2. it is giving an error char keypadPort at PORTD; on this line.

    i really want to compile it and need its hex file.

    please help

    ReplyDelete
  11. GREETINGS ONCE AGAIN

    I have tried your code many times to compile. please help me why it is not compiling my compiler is working fine.

    PLEASE REPLY AS SOON AS POSSIBLE

    ReplyDelete
  12. Make sure that you included the keypad library.

    ReplyDelete
  13. can you end to me the code please
    eng_ahmed_osama@hotmail.com

    ReplyDelete
  14. Please tell me the library file for keypad.. and what more header files are to be included.

    WAITING FOR YOUR REPLY. THANKS

    ReplyDelete
    Replies
    1. You can see Library Manager tab left of the project window. Check the check box of required libraries.

      Delete
  15. GREETINGS MY PROBLEM REGARDING ITS SIMULATION IS SOLVED THANKS FOR YOUR HELP. NOW SOME THING WHICH IS NOT SUPPOSED TO BE OCCURRED IS BEING OCCURRED.

    WHEN THE SIMULATION STARTS THE LED AT PORT A pin 0 starts glowing but instead it should glow when ACCESS is being granted. before it must not glow. If am right then please provide appropriate solution. else guide me what is the real logic behind it.

    PLEASE REPLY AS SOON AS POSSIBLE
    wait

    ReplyDelete
  16. proteus simulation code
    valisha.dcosta@gmail.com

    ReplyDelete
    Replies
    1. Hello,
      Sorry the file is missing, i will try to build a new one. Sorry for late reply.

      Delete
  17. sir can you also send me the proteus file?
    here's my email betoy.aguila@gmail.com

    thank you very much!!

    ReplyDelete
    Replies
    1. Hello,
      Sorry the file is missing, i will try to build a new one. Sorry for late reply.

      Delete
  18. my lcd is taking random data after "Enter Code" an after 3 attempts shows Access denied

    ReplyDelete
  19. No problem in the code for taking random character, it works perfectly. Is that taking randomly always? check the keypad connection. the connections in come of the available keypads are not in order, check our keypad tutorial here.

    Its code protected for THREE wrong entry, after that the device cannot be accessed, you need to reset it.

    All of you are welcome to our group, get the link from the above blog post.

    Regards,
    Vishal

    ReplyDelete
  20. Greetings,
    Please, can you mail me the pdf of the project, and if you do...would it be ok if I modify it while practicing?

    wi.turtlez@gmail.com

    Also, I've been given a project on
    "Microcontroller based electronic locking system module"
    ...and I'm not really sure how to go about it....can you help.
    Thanks,
    Chuck Konta

    ReplyDelete
    Replies
    1. I had written only this much of matter, so there is no PDF available. I hope the above explanation is enough. There is no problem for using the code or design, but if you post this project somewhere please add a reference.

      Delete
    2. Use the Discussion Group link please.

      Delete
  21. can you plz send me proteus file...i am having difficulty in making 1....
    what does the circuit U1 do thats on top right if the figure..
    aazib.gil@gmail.com

    ReplyDelete
  22. sir can you pls mail the code and proteus file

    my id is
    swap_k007@rediffmail.com

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete
  24. hello .... i tried your code and it compiles just fine but i can't seem to simulate it in proteus .... could you please send me the whole project(code and simulation ) on fasika47@gmail.com
    .i would be really great-full....

    ReplyDelete
  25. can you please send me proteus file at harshits996@gmail.com

    ReplyDelete
  26. kindly send me proteus file at focusme19@gmail.com...

    ReplyDelete
  27. can u sent to me the project 'code' to my email

    ir_student007@yahoo.com

    hope u can help me.. n_n

    ReplyDelete
  28. please send the project code in notepad and proteus file. thank you.
    julius_cimeni@yahoo.com

    ReplyDelete
  29. can u pls mail the program code my id is
    sukrut_goswami@yahoo.com

    ReplyDelete
  30. Hello,Sir

    Thanks for yr sharing.
    I already chosen this project as my school final project.
    Please send me this source in C (.txt) , other .pdf files and useful references links to my mail: paing.peace@gmail.com.

    Thanks for yr kindness.
    Paing Khant

    ReplyDelete
  31. There is a link posted at the end of the article, you can download HEX file and C file (From Facebook Group).

    ReplyDelete
  32. Sir, i can't download from http://www.scribd.com/doc/86640317/Electronic-Code-lock.
    i cannot purchase thus also cannot download because of our country. Can't do copy/paste. But i read and typed in Notepad and complied in mikroC Pro. when write, occur 4 data error. So please send me Source Code in C with Notepad.
    i downloaded HEX file from FB Group.
    Thanks a lot,sir

    ReplyDelete
  33. sir im really cant access the facebook link...can u send the source code to my emaIl (sunkgacrewz22@gmail.com) asap..please sir..im doing this project for my final year. hOpe u will help me.

    ReplyDelete
  34. Does it work well? Could it surely secure anyone's home?

    Master Keys Farmers Branch

    ReplyDelete
  35. Is the upper portion of the circuit given at the right corner of the application circuit
    necesary?Those who have worked with this circuit please help me.

    ReplyDelete
  36. please do you PIC code of conveyor belt project. if you have. please send me safdar.rasul@gmail.com

    ReplyDelete
  37. That's an awesome concept with microcontrollers. Security system is very essential in each and every technology nowadays. Password must be complex and should not be in an easy way to analyse by anyone. PIC microcontroller is used to perform various kinds of tasks which is used control a production line and microcontrollers are programmed as timers. It is used in control systems such as door lock mentioned in the blog, alarm system, phones,etc.

    ReplyDelete
  38. I have a problem with "FF", I received this message " Undeclared identifier 'FF' in expression

    ReplyDelete
  39. Check for FF in the program.
    I can identify it if you paste the code snippet here.

    ReplyDelete
  40. This comment has been removed by the author.

    ReplyDelete
  41. Can u send to me the PIC source code ...thanks
    Email: max_yong1994@hotmail.com

    ReplyDelete
  42. Hi,I'm very interested on the electronic lock. I would really appreciate it if you could please email me the whole project(code and simulation(proteus)). My email is ecejfh@gmail.com. Continue with your great work. Thanks

    ReplyDelete
  43. hie sir,
    i need a c program and if possible a hex file so that i can run it on proteus. indeed i tried searching the program in ur fb lick but i wasn't able to find one. hope u can send me on my mail id nivishkamdar@gmail.com

    ReplyDelete
  44. hello sir,
    i need a c program and if possible a hex file so that i can run it on proteus. indeed i tried searching the program in ur fb lick but i wasn't able to find one. hope u can send me on my mail id azhanihasnolhadi@gmail.com

    ReplyDelete
  45. Sir if im using 4x4 keypad which part of programming i have change. And can u show me a circuit with buzzer sir
    sitihafizah9491@gmail.com

    ReplyDelete
  46. Thank you sir for the post

    Simulation with proteus gives those errors with (PIC 16F877A):

    [pic16load] PROGRAM or EEPROM data has invalid address [2000] for this device
    [pic16load] PROGRAM or EEPROM data has invalid address [2001] for this device
    [pic16load] PROGRAM or EEPROM data has invalid address [2002] for this device
    [pic16load] PROGRAM or EEPROM data has invalid address [2003] for this device
    CFGWORD2 not implemented

    I used the following properties:
    {PACKAGE=DIL40}
    {TRACE_DEFAULT=1}
    {PRIMITIVE=DIGITAL,168771}
    {MODDLL=PIC16}
    {MODDATA=256,255}
    {ITFMOD=PIC}
    {CODEGEN=MPASMWIN}
    {PROGRAM=LOCK PROJECT\LOCKSYSTEM EN MOI.HEX}
    {CLOCK=8MHz}
    {CFGWORD=0x3FFB}
    {DBG_RANDOM_PMEM=0}
    {DBG_RANDOM_DMEM=0}
    {DBG_STARTUP_DELAY=0}
    {DBG_WAKEUP_DELAY=0}
    {DBG_ADC_BREAK=0}
    {DBG_GENERATE_CLKOUT=0}
    {WDT_PERIOD=18m}
    {ADC_RCCLOCK_PERIOD=4u}
    {ADC_ACQUISITION_TIME=20u}

    any help please

    ReplyDelete
  47. thanks for sharing this information , its nice to see, the devices are very accurate to work, thanks for sharing :)
    Alarm System in India

    ReplyDelete
  48. Hi sir, i,ve been working on this project since last four days. I'm using AVRatmega8 as the microcontroller...if you could send the code of complete project along with the buzzer functionality..and other relevant details that will be helpful.
    My email id is:vanup08@gmail.com
    Thanx a ton in advance.

    ReplyDelete
  49. Wow...... all are so technical part.... is it for Door Lock Access Control??

    ReplyDelete
  50. pls help me with the hex file....sadiqyusuf33@gmail.com

    ReplyDelete
  51. am constructing this code lock as my project and i cant get the hex file and that's all i need now to complete the project work...pls i really need help.. this is my mail i will be very grateful if some one will help me out
    sadiqyusuf332gmail.com

    ReplyDelete
  52. This comment has been removed by the author.

    ReplyDelete
  53. Hello Sir Vishal! I am a student and currently working on my thesis project. I saw this project and downloaded the code and also imitated the circuit you provided because I wanted to make it as a reference while I'm developing our project. Unfortunately, when I started to test it in proteus (I imitated the circuit you uploaded), and tried to enter to password (*2345#) nothing happens anymore ... Right now, I still trying to figure out & troubleshoot the circuit and understand the code at the same time. I'm really hoping that I could get in touch with you for further information and advise. I will greatly appreciate it. I am also asking if you can send me the original proteus file and code (if available) you made so that I could study it further. Here is my email address, Sir: shinnacuray0929@gmail.com Thanks and More Power!

    ReplyDelete