To begin with, this is easy and Simple Electronic Code Lock Circuit; to open door or box no need of key we can use special code instead.
Also, this circuit uses buttons and code to the open lock, so only correct code can open and wrong code will not work.
Circuit Working:

Parts List:
| Components | Quantity |
|---|---|
| Resistors | |
| 1/4 watt 1k | 2 |
| Semiconductors | |
| Transistor BC547 | 1 |
| Diode 1N4007 | 1 |
| Relays | 1 |
| Mini switches (ON/OFF) | 8 |
This code lock circuit is famous because design is very simple, as it uses smart code with only one main part and 8 push buttons.
How this lock circuit work?
To turn ON the relay we must press all 4 buttons S1, S2, S3, S4 together and if we press any wrong button like S5 to S8 relay will not work and lock will stay closed.
Very important: power supply voltage must be same like relay voltage, because small transistor like BC547 can take current up to 50mA.
Also, if relay needs more power then use transistor like 2N2222 it can take 0.2A.
Formulas:
Here, relay Coil Current is tool for finding how much resistor (R) needed for BJT transistor to turn ON relay coil; so lets see what is inside the formula:
R = (Us – 0.6) × hFE / Relay Coil Current
- R is resistor value in ohms Ω we want to find this.
- Us is power supply voltage in volts V.
- hFE is BJT gain how much it can increase base current.
Relay coil current refers to the amount of current, measured in amperes (A), required to turn the relay ON.
How to use this formula:
Voltage Drop:
(Us – 0.6) means voltage drop at base emitter of BJT and most BJT have drop of 0.6V so we subtract it from power supply; also this give us voltage for base resistor.
Base Current Gain:
hFE show how much transistor multiply base current, like bigger hFE = less base current needed to turn ON relay.
Use formula R = V / I.
Furthermore, this will help find correct resistor R so enough current goes in base of BJT which is not too much.
In simple words:
Also, this formula help choose good resistor so transistor work correct and switches ON relay coil with right amount of current.
How to Build:
To build a Simple Electronic Code Lock Circuit follow the below steps for connections:
Identify Parts:
- First, check all parts in circuit diagram are there and be sure all parts match the needs of circuit.
Make Circuit:
- Next, connect power supply positive (+) to relay common pin, connect relay NO (normally open) pin to positive side of code lock system.
- Connect power supply negative (-) to negative side of code lock.
Button Connection (S1 to S8):
- Now put S1, S2, S3, S4 in parallel and connect this group to relay input.
- Also, connect S5, S6, S7, S8 to ground to stop wrong press from turning ON relay.
Use Resistors:
- Also, put resistors where needed to save parts and control current flow.
LED (Optional):
- If we use LED then connect it with resistor in parallel to relay coil and this will show light when relay is ON.
Soldering Work:
Test Circuit:
- First, press all buttons S1 to S4 together to turn the relay ON and unlock the door and if we press the wrong button, the relay stays OFF.
Be Safe:
- Before power ON check all wires and part values and if we are not sure how to make circuit then ask someone who knows or learn more before trying.
Conclusion:
Overall, Simple Electronic Code Lock Circuits offer more advantages than traditional key locks because users can change the code easily, monitor who enters and connect them with other security systems.
Finally, people use these circuits in homes, offices, factories and many other places.