Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   

27 December 2009
Author: Giorgos Lazaridis
Simple Keycode Lock


The circuit on a breadboard for test. This circuit has the CD4072 Chip included and can be used with touch keypad as well.

Imagine that you sit on your PC desk, you pull the keyboard, the mouse is near by, you click the button and the computer boots. Now imagine the same scene, but instead of pushing just a button, you enter the security code! That was one of my imaginations when i was a kid. Nowadays, i could make a more complex systems, with security code, LCD display and hardware key, but i decided to make a more simple yet secure circuit for the other 'kids' that want to boot with more than just a cold pushbutton.


Here is a video from the circuit in operation!



The Circuit

There are more simple but less secure circuits. This circuit has a 4-digit security code that is hardware selectable. It can have as many 'wrong' digits as you like, but up to 4 'correct' digits. Also, one digit cannot be more than once in the security code. Suppose for example that you choose to have 10 digit keypad with numbers from 0 to 9. One code could be the number 5293, or the 7520, but the code 4429 is wrong! The digit '4' is more than once in the code and that cannot happen.

The schematic digram is as follows:




Each 'correct' key press will SET a flip-flop. When the 4th flip-flop is SET, the relay will be armed through the PNP transistor. Whenever a 'wrong' button is pressed, all 4 flip-flops will be RESET and the code must be entered again from the beginning. Also, if the code must be entered in the correct order. If for example the code is 1234 and instead you press 1 and then 3, the flip-flops will also RESET.




The Keypad

To be more secure, the keypad should be on another remote PCB

The keypad could be normal pushbuttons

The keypad can have as many keys as you like. From the circuit you have 5 inputs, the D1, D2, D3, D4 and the ERR. The 4 D inputs are the 'correct' buttons. Each one must go to one and only key! For example, someone could connect the D1 to key number 4, the D2 to key number 2, the D3 to key number 9 and D4 to key number 5. The code to open the lock would be '4295'.

All the other buttons that will reset the circuit must be connected to the 'ERR' input. So if the keypad had 10 keys and the code was '4295' the keys 1,3,4,6,7,8 and 0 must be connected to the ERR input.

Here is an example of a keypad connection. A ribbon-cable is used to interface the keypad to the PCB. The four wires that correspond to the 4 buttons of the code are separately connected to the 4 D inputs. ll other wires are connected to the ERR input.



The keys can be a push-button with one normal-open contact, connected to the positive (VDD) of the circuit. Also, because i use CMOS, the keys could be touch-plates on the PCB itself. Look at the following PCB layout:

The circuit is designed to operate at any voltage between 5 and 15 volts. The only thing that needs to be changed is the relay. The one that i use is a 5V DPDT, but you can use whatever relay you like.




A nice print-out with some kind of artwork and holes that correspond to the keypad PCB-keys, can mask the keypad and make it more elegance



Bill Of Materials
Resistors
R1-5Resistor 47 KOhm 1/4 Watt 5% Carbon Film 
R6Resistor 4.7 KOhm 1/4 Watt 5% Carbon Film 
Transistors
Q12N2907 General purpose amplifier and switching transistor 
ICs
IC1CD 4013 Dual D-Type Flip-Flop 
IC2CD 4013 Dual D-Type Flip-Flop 
IC3CD 4081 Quad 2-input AND buffered B series Gate 
IC4CD 4072 Dual 4-input OR Gate 
Misc
RELAYRelay DSDP miniature 5V relay 




A more simple circuit

This circuit does not have the 4072 chip. It has the same functionality, it is simpler, but it cannot be used with touch keypads.

If you will use normal push-buttons for the keypad, i suggest you use the following circuit instead. This is exactly the same circuit as the previous one, with the only difference on the reset. It does NOT use the 4072 CMOS for gathering the reset signals. Instead, it uses diodes connected as OR gates. It has the same operation as the previous one, but it is not recommended to be used with a touch keypad! Only with pushbuttons. This circuit is significantly simpler and equally secure to the previous one. It needs a smaller PCB an one chip less.

Here is the schematic:







Bill Of Materials
Resistors
R1-5Resistor 47 KOhm 1/4 Watt 5% Carbon Film 
R6Resistor 4.7 KOhm 1/4 Watt 5% Carbon Film 
R7Resistor 22 KOhm 1/4 Watt 5% Carbon Film 
Diodes
D1-41N4148 Switching Diode 
Transistors
Q12N2907 General purpose amplifier and switching transistor 
ICs
IC1CD 4013 Dual D-Type Flip-Flop 
IC2CD 4013 Dual D-Type Flip-Flop 
IC3CD 4081 Quad 2-input AND buffered B series Gate 
Misc
RELAYRelay DSDP miniature 5V relay 







Relative pages
  • Basic transistor circuits
  • Learn about the most popular PC Cooling methods
  • 4000 series IC pinouts
  • Learn how to interface ICs





  • Comments

      Name

      Email (shall not be published)

      Website

    Notify me of new posts via email


    Write your comments below:
    BEFORE you post a comment:You are welcome to comment for corrections and suggestions on this page. But if you have questions please use the forum instead to post it. Thank you.


          

  • At 31 May 2015, 7:28:02 user rafael wrote:   [reply @ rafael]
    • hey i want to ask you something about this circuit. what is the Q' output for the 1 to 3 FF suppose to be?


  • At 14 November 2013, 1:54:54 user J__ wrote:   [reply @ J__]
    • It's more cheap and easy use a CD4017, because the state machine it's already implemented.


  • At 28 July 2013, 7:27:33 user Fung wrote:   [reply @ Fung]
    • Actually I learned a lot from this circuit...

      After testing this circuit on breadboard, I found that it would not reset after pressing the correct key-codes. For example I set the password as "9652", I enter it and the green LED lights up (which means a correct code sequence is entered), but it doesn't reset unless a wrong/reset key is pressed.

      May be an auto-reset feature should be added? I referred some resources and found that it can be done by a 555 timer and some parts.

      Based on your circuit, I made another version which also include the feature mentioned above and the "disable the keypad when green LED lights" (enables again after 5 seconds).


  • At 3 October 2011, 18:22:44 user Kammenos wrote:   [reply @ Kammenos]
    • @takky without breadboard or PCB it is dead cheap, less than $5


  • At 2 October 2011, 14:14:03 user takky wrote:   [reply @ takky]
    • hello sir,
      plz tell me what would be the estimated cost of this circuit.


  • At 3 September 2011, 18:07:23 user Kammenos wrote:   [reply @ Kammenos]
    • @Suryansh i'm sorry but i cannot do that. It will require to spend a lot of time to design and test the PCB.


  • At 2 September 2011, 15:58:45 user Suryansh wrote:   [reply @ Suryansh]
    • @ Kammenos
      Sir I am sorry I wasted your time ...Actually one of my Ic's Pin was broken..thats why I was Getting the Problem with this ckt....But now its working perfect...Anyways thanx for ur time and help...
      It would be a gr8 help indeed If u would provide me with a SINGLE SIDED PCB LAYOUT of this ckt.
      As I m not able to make an effecient SINGLE SIDED LAYOUT (using Eagle and Circuit Wizard) by myself..
      Thanx in advance


  • At 25 August 2011, 14:15:26 user Suryansh wrote:   [reply @ Suryansh]
    • Ya thanx i'll do the same


  • At 23 August 2011, 17:24:10 user Kammenos wrote:   [reply @ Kammenos]
    • @Suryansh you need to run some tests to see what happens. I opened a forum thread for you to follow. Please continue this conversation there because it may become a long thread:
      http://pcbheaven.com/forum/index.php/topic,1300.0.html


  • At 23 August 2011, 13:25:32 user Suryansh wrote:   [reply @ Suryansh]
    • srry i forgot to mention it i used the one with the 4072


  • At 23 August 2011, 13:19:50 user Kammenos wrote:   [reply @ Kammenos]
    • @Suryansh which circuit you use?


  • At 23 August 2011, 13:15:18 user Suryansh wrote:   [reply @ Suryansh]
    • Thanks 4 ur response I checked all the connectns r Ok and when I tried this on my breadboard the same happend but to reset ,sometimes I have to hold the reset key ,somtims i have to tap it more than once and sometimes oly one tap,
      i m totaly saturated .plz help
      IM DOING DIS CKT FOR MY MINI PROJECT iN ENGINEERING(3rd year)


  • At 22 August 2011, 17:48:34 user Kammenos wrote:   [reply @ Kammenos]
    • @Suryansh i suppose that either you use the incorrect FF output for the third FF (Q instead of Q-). Or the reset line has a problem. Which circuit are you using? The one with the 4072 or with the diodes?


  • At 22 August 2011, 14:45:17 user Suryansh wrote:   [reply @ Suryansh]
    • Hi @Kammenos;
      I am following ur projects,crkts.and they are just awesome...At present I am trying ur SimpleKeyCodeLock...I am using CIRCUITWizarad software for making PCB and I feed ur ckt in it and when I simulate the circuit it works fine .BUT......
      When I Dirctly
      PRESS AND HOLD the 4th(i.e,last FlipFlop)button for a while and then release it(without pressing any of the other Buttons),then my Solenoid i.e; the o/p goes high...WHY???What should I do???
      Plz help me its Ergent:-(


  • At 1 June 2011, 4:41:04 user Kammenos wrote:   [reply @ Kammenos]
    • @Dan sure it can. add 3 more FF gates, AND and OR gates as required.


  • At 1 June 2011, 0:47:24 user Dan wrote:   [reply @ Dan]
    • I am in need of a seven digit code lock. Is this design able to expand to accommodate a seven digit code?


  • At 19 June 2010, 15:27:32 user angel wrote:   [reply @ angel]
    • Thanks a lot for your help sir, will give a try


  • At 19 June 2010, 13:52:10 user Kammenos wrote:   [reply @ Kammenos]
    • The JKFF will act as toggle flip flop when both inputs are HIGH (all other states are same). So, No, it would not work.


  • At 19 June 2010, 11:43:47 user angel wrote:   [reply @ angel]
    • Thanks a lot sir, i have another question, can this circuit be implemented with a JK flip flop??


  • At 19 June 2010, 10:56:27 user Kammenos wrote:   [reply @ Kammenos]
    • Indeed there is a situation where Q' and Q become HIGH, but the circuit only uses the Q' output. So, here is the truth table of the Flip Flop(i use 1 for HIGH and 0 for LOW and x for NO CHANGE)

      S R - Q - Q'
      0 0 - x - x
      0 1 - 0 - 1
      1 0 - 1 - 0
      1 1 - 1 - 1

      So, when S and R are HIGH, the outputs Q and Q' are normally BOTH HIGH.
      Suppose now that the code is 1234. I will only talk for the last FLIP FLOP (most right one). The R is LOW. When no key is pressed, the S is also LOW from the pull down resistor. From the truth table, R-0 and S-0 makes no change to the outputs. Now you press the digit 4 first. This makes S HIGH. But from the 3rd FF Q' is also HIGH, so the AND gate (IC3C) becomes HIGH, the OR gate (IC4A) also HIGH, and this makes ALL reset inputs HIGH. As long as you hold the digit 4, the inputs S and R of the flip flop will be simultaneously HIGH. Look what happens at the truth table in this situation. Both Q and Q;' are HIGH!!! When you leave the 4th digit, everything returns to LOW. So, S and R are LOW, and the FF does not change state - this means that it remains to RESET. Ther elay will be armed ONLY when the Q' of the 4th FF is LOW! This can only happen, when S is HIGH (the 4th digit is pressed) and R is LOW (no reset signal comes from another button or the OR gate). Did i solve your problem?


  • At 19 June 2010, 10:05:22 user angel wrote:   [reply @ angel]
    • Sir i am having lots of confusion. i mean assuming the code is 1234, then i first press 4, from the circuit, S will be high and R will also be high,so how Q becomes low and Q' becomes high. sir please help me with that, it's urgent


  • At 19 June 2010, 10:01:17 user Kammenos wrote:   [reply @ Kammenos]
    • Yes, Q is LOW


  • At 19 June 2010, 9:58:37 user angel wrote:   [reply @ angel]
    • then the Q should be low if i press 4?


  • At 19 June 2010, 9:55:43 user Kammenos wrote:   [reply @ Kammenos]
    • Indeed it will reset, and the Q' will go HIGH.


  • At 18 June 2010, 15:57:25 user angel wrote:   [reply @ angel]
    • for the first circuit(the one with the 4072 CMOS for gathering the reset signals), if the code is 1234, and assuming i first press 4, the circuit should reset, right? then Q' will be high or low?? can you please help me


  • At 21 May 2010, 14:02:38 user waleed wrote:   [reply @ waleed]
    • so thats i need i request you to send me a original data sheet of circuit that you make on bread board in video
      thanks


  • At 21 May 2010, 13:58:18 user Kammenos wrote:   [reply @ Kammenos]
    • Exactly what is it that you do not understand? How the AND gates (IC3) work along with the FLIP-FLOP (IC1-IC2)? You are talking about the first or the second circuit?


  • At 21 May 2010, 13:54:10 user waleed wrote:   [reply @ waleed]
    • i mean i did not understand about your ic2a or ic3b and so on or gates
      plz reply me


  • At 21 May 2010, 13:47:41 user wali1012001 wrote:   [reply @ wali1012001]
    • i did not understand your circuit [drawing] plz do it simple circuits for me or send it to my email
      thanks


  • At 21 May 2010, 13:46:11 user Kammenos wrote:   [reply @ Kammenos]
    • Hi waleed. You mean you cannot see it clear? Click on it and it will maximize. Most of the images will maximize on click.


  • At 21 May 2010, 13:32:38 user waleed ahmad wrote:   [reply @ waleed ahmad]
    • i did not understand your circuit [drawing] plz
      clear this problem for me

      thanks


  • At 1 March 2010, 5:46:20 user Kammenos wrote:   [reply @ Kammenos]
    • Hello yliezabeth,
      of course you can change it. Look the video and read the section "The keypad". It is easy,


  • At 1 March 2010, 3:12:32 user yliezabeth wrote:   [reply @ yliezabeth]
    • Sir, good day..

      in this circuit,can i change the number combination?


  • At 24 January 2010, 20:41:36 user Kammenos wrote:   [reply @ Kammenos]
    • Hello q-terie
      You cannot have the same number more than once!


  • At 24 January 2010, 20:37:25 user q-terie wrote:   [reply @ q-terie]
    • Can i use code like "2244"? How?
      Thanx


  • At 15 January 2010, 16:37:23 user Kammenos wrote:   [reply @ Kammenos]
    • To do this, you need to connect all 4 'correct button' inputs to the 4 unused inputs of the 4072 (4072 pins 9-10-11-12). The output of this IC (pin 13) will be connected to the SET of another flip-flop. Then you will connect the RESET of this new flip flop to the output of the 4072 pin 1, that is the reset signal from an error button. The D and CLK inputs of the new flip flop goes to 0V. Now, you connect the RED LED to Q output of the flip flop, and the GREEN LED to the Q minus of the flip flop.
      I have not test it but it could work. Test it and post the results.


  • At 15 January 2010, 16:24:05 user -lanz- wrote:   [reply @ -lanz-]
    • I want to add LED's to this circuit.
      Like this:
      A red LED ON from the begining.
      A green LED ON and the red LED OFF when correct button was pressed.
      How to do it?


  • At 29 December 2009, 6:53:27 user Kammenos wrote:   [reply @ Kammenos]
    • Exactly Lanz, All other to err. I kept it as simple as possible.


  • At 29 December 2009, 5:09:07 user -lanz- wrote:   [reply @ -lanz-]
    • Well yeah,its the same.
      U mean,all other button except the 4 code button should be connected to ERR?
      Simple is nice Kammenos,rather than programming a microcontroller.


  • At 28 December 2009, 22:03:36 user Kammenos wrote:   [reply @ Kammenos]
    • Oh, i got it now Lanz. Yes i could do that and it would be the same as i do now. But it would require more cables to draw on the circuit and this makes me sick sometimes. That's why i prefer to have separated connections. It is the same. Sometimes i should use more than i should, like now that i have separated on the top-right corner for the IC power supplies. It could be better with just one, but i think i am used to this way.

      As for the code. There are 4 connectors, D1 through D4. Those should be connected to the 4 buttons that you want to have the code. For example, if you want to have the code '4521' you connect D1 to button 4, D2 to button 5, D3 to button 2 and D4 to button 1. All other buttons (as many as you like) should be connected all together to the 5th connector labeled 'ERR'. To change the code, you need to change the wires of the buttons accordingly. I know this is not an elegant way, but i did not want to use a microcontroller for this circuit. By the end of this week i will have prepared the video of this circuit in operation (like we do for all our circuits and experiments).


  • At 28 December 2009, 15:55:52 user -lanz- wrote:   [reply @ -lanz-]
    • Well abt the picture,now i got it.Thanx
      What i meant was to connect all GND connection to 1 GND source and all VCC connection to 1 VCC source.

      How to set the desired code we want and how to change it?


  • At 27 December 2009, 17:01:03 user Kammenos wrote:   [reply @ Kammenos]
    • Hi Lanz,

      click on the schematic and you will get it into full size 1672px x 832px.

      "It will be perfect if u could connect the circuit to GND n VCC together."
      I do not understand what you mean by this.

      Also, please, subscribe to the comments board. If you do, you can edit your previous posts and not need to repost a new comment, if you only want to add something


  • At 27 December 2009, 15:53:41 user Lanz wrote:   [reply @ Lanz]
    • Ur schematic picture is blur.
      It will be perfect if u could connect the circuit to GND n VCC together.


  • At 27 December 2009, 15:43:14 user Lanz wrote:   [reply @ Lanz]
    • Nice,will give a try.



    delicious
    digg
    reddit this Reddit this
    Faves



     HOT in heaven!


    NEW in heaven!



    New Theory: AC electric motor working principle



     Contact     Forum     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS   

    Site design: Giorgos Lazaridis
    © Copyright 2008
    Please read the Terms of services and the Privacy policy