This is a simple but effective code lock circuit that has an automatic reset facility. The circuit is made around the dual flip-flop IC CD4013.Two CD 4013 ICs are used here. Push button switches are used for entering the code number. One side of all the push button switches are connected to +12V DC. The remaining end of push buttons 2,3,6,8 is connected to clock input pins of the filp-flops. The remaining end of other push button switches are shorted and connected to the set pin of the filp-flops.
The relay coil will be activated only if the code is entered in correct sequence and if there is any variation, the lock will be resetted. Here is correct code is 2368.When you press 2 the first flip flop(IC1a) will be triggered and the value at the data in (pin9) will be transferred to the Q output (pin13).Since pin 9 is grounded the value is “0” and so the pin 13 becomes low. For the subsequent pressing of the remaining code digits in the correct sequence the “0” will reach the Q output (pin1) of the last flip flop (IC2b).This makes the transistor ON and the relay is energised.The automatic reset facility is achieved by the resistor R11 and capacitor C2.The positive end of capacitor C2 is connected to the set pin of the filp-flops.When the transistor is switched ON, the capacitor C2 begins to charge and when the voltage across it becomes sufficient the flip-flops are resetted. This makes the lock open for a fixed amount of time and then it locks automatically. The time delay can be adjusted by varying the values of R11 and C2.

Circuit diagram with Parts list.


  • Assemble the circuit on a good quality PCB.
  • The circuit can be powered from 12V DC.
  • Mount the ICs on holders.
  • The L1 can be a 12V, 200 Ohm SPDT relay.
  • Capacitor C1 should be tantalum type.
  • The C1 and C2 must be rated at least 25V.


  1. sir
    In ic1b and ic2b wheather will have the supply connection

  2. good day. i have a project digital combination code lock due tomorrow, pls help me. someone made fun of my schematic diagram and swtiched the pins intended for the LCD and for the keypad. now im having a very hard time programming the PIC and header since the pin configurations are all messed up. pls help… look at my name. I am using a PIC16F877 with 2X16 4-bit LCD based display. and 3X4 4 bit keypad with decoder. God speed!

  3. sir i hav been working on this project for 1 week, without the reset circuit its working fine, but once it is included the relay is not being energised,pls help sir

  4. Sir, I have been working on this project for two days. All connections are
    made accordingly to your diagram. I also implemente it on multisim. Its working fine on that.But when I implementing on breadboard even the IC doesnt support output is constant and not varying with changing the clock cycles.
    Please help

  5. Could you please submit a simulation of this circuit using multisim .
    I am facing this problem but i am simulating the exact circuit what is given Please Help!!

  6. Sir may I use CD4013BE or CD4013BC instead of CD4013???

  7. which software is used to run this circuit in computer. help me sir….

  8. plz can u tell whats the function of relay coil in this circuit.. and where the output have to be seen……….its very inportant for me.if possible plz upload the breadboard connetion. thanku

  9. nagasundhari

    hai sir i want to know the application of this digital code and which purpose it willbe used????

  10. Sir,
    I tried simulating in Multisim, but i have no idea what to use as the spdt relay and what difference would i see once the simulation is complete
    pls help
    Thank u

  11. thank you sir.
    my circuit worked i have raised the holding time by about 7sec. i have used
    a 3300Mfd capacitor and a 2.2k resistance.

  12. Seetharaman

    Hi Rahul to increase the holding time, raise the value of R11, C2 or both. Please read last two lines of the description. may be 1000uF or R11 to 2.2K ohms.

  13. sir
    when i activate my lock the relay activates only for a fraction of time and again deactivates I could not find the error .

  14. sir
    i could not understand why my Vce is not raising at all it is about 0.04 v .

  15. sir
    is it because of the capacitor c2 I have used a 100mf 63v capacitor..

  16. sir
    sorry to bother u again but the circuit is still not working when i activate the lock it the out put is only for small moment the out put still not proper

  17. sir
    thanks a lot for your time and advice..

  18. seetharaman

    Hi rahul open circuit voltage will be full. once you connect the transistor it will fall down to 0.7 volts when on.

  19. sir
    u r correct E&C of the transistor i have connected are interchanged.
    sir the data sheet says V EB should be maximum 5v. Initially when the lock is off it is about 0.07 v but when the lock is turned on it raises to about 11v .Sir will it damage the transistor ?? I have checked it without connecting the transistor i.e between the 1.5k resistor and emmiter of Q1, or it will be different when i connect the transistor..

  20. seetharaman

    Hi Rahul check EBC of Q1. this transistor is different from normal small signal TO92 transistors. Since you have indicated that vbe is 9.51v. cannot be when transistor is forward biased, it can be at a maximum of 0.7volts only. it looks your emitter and collector are interchanged please refer the datasheet.

  21. Sir,
    I tried simulating in Multisim, but i have no idea what to use as the spdt relay and what difference would i see once the simulation is complete
    pls help
    Thank u

  22. sir
    I have corrected my circuit.. but my relay is still not energised . But the voltage between the base of Q1 & gnd is 10.8v (initially) wen i activate the lock it drops to around 1.8 v. which sows my circuit is working.
    The EC & EB voltages of Q1 are as follows.

    initial EB 0.32v when the lock is on EB 9.51v
    EC 8.68v EC 8.68v
    I could not understand whats going on..

    sir please reply as soon as possible.

    • hi rahul bro can u send the correct circuit to me even me to having the same problem in that 9 pin is data pin then how this will reset the whole circuit so please send me the correct circuit bro

  23. how is the data line going to reset the circuit…..???

  24. I am still confused about pin 9 its still grounded . Pin 9 is the data line of D flip flop.where should it go .
    please correct the circuit as soon as possible.

  25. hi
    can any one help me with this circuit . Is this circuit working??I have assembled it for my project but it didn’t work.


  26. Very knowledgeable article. can we use it in a computer security system??

  27. sir, can plz anyone tell me d way v can change d code? n plz, tell me for wat kind of locks v can use it?

  28. Can we change the code in this circuit sir..?

  29. Pin 9 should not be grounded, it is a mistake. Gentleman who made this drawing was too much excited and in a hurry to share so he left two mistakes in the schematic for people to wonder. Never mindm search the pin configuration on the net and use only IC CD4013 (not CD4049). Cheers….

    • that was a typo error from my part. i have corrected the circuit

      thanks for pointing the error

  30. hammedshekoni

    pls if dere isn’t a grounded pin 9 in ic1a which pin is den grounded, and wld it be at d relay that there wld be an output after entering the code or pushing d right buttons

  31. seetharaman

    Hi Chianmy sorry it was on the same frame this circuit was drawn so please leave those words CD4049 use CD4013 instead.

  32. Why is it mentioned as ‘Digtal code lock using CD4049’ below the circuit diagram?

  33. Karthiga

    please can you upload the breadboard connection for this circuit

  34. seetharaman

    Hi Ilija you are correct IC1 pin no9 shown as going to ground is wrong. delete that line other wise the circuit is correct.

  35. yes, what does it mean pin 9 ?!? I don’t understand it

  36. Can you please tell me what will happen when the relay is energised? Where do you put the motor? Thanks!!



    Thank u sir,i am fully impressed by getting this topic.&soved my doubts.

  39. plz give its state diagram to understand its working….plz plz …i have just 2 hrs to submit this project and perform in viva

  40. sory i want to ask again,, i have been made it, but why it doesn’t work?? i gave it suplay 12 v and i use relay hrs4h and connect it to DC motor,, but the DC motor doesn’t work..

  41. Seetharaman

    Hi Naufan L1 can be the solenod coil of the latch or through this relay’s contact you can operate the locks solenoid.

  42. excuse me,, i want to ask what is the function ogf the relay coil??

  43. Hi Sir. how can i change the code if i want to change it beside changing it from the circuit’s wire? thank you.

  44. manish kumar

    it is a very good projects but there is not information of realy and how to control have to use your mind to control the motor.

  45. N.Nagaraj

    Thanking you for giving the code lock circuit.
    By this my problem is solved. Thanking you once more