Digital Padlock using Logic Gates

In this post we are going to use logic gates and D-Type Flip-Flop circuits to create a 3-bit digital padlock with a stored combination that can be reset.

Let’s first investigate how we are going to store the 3-bit combination in our circuit using 3 D-Type Flip-Flop circuits.

D-Type Flip-Flop Circuits

A D-Type Flip-Flop circuit is a circuit used to create a memory cell to store 1 bit of information (0 or 1). It is built using four NAND logic gates connected as follows:

We represent a D-Type Flip-Flop Circuit as follows. You can change the input values D and E by clicking on the corresponding buttons below to see the impact on the outputs Q and Q.


You can also test the behaviour of a D-Type flip-flop circuit using our online simulator:
Click on the above circuit to open in a new window.

A D-Type Flip-Flop Circuit is used to store 1 bit of information. It has two input pins (Called D (Data) and E (Enabler) and two output pins (Q and Q = NOT Q).

The truth table of a D-Type Flip-Flop circuit is as follows:

When the enabler input E is set to 1, the output Q can be set to the Data input D.
When the enabler input E is set to 0, the output Q cannot be changed. It remains as its previous value. In other word it retains its value. This is why this circuit is used to create memory cells (e.g in the RAM).

Random Access Memory (RAM) consists of billions of data cells, each data-cell uses a D-Type flip-flop circuit.

Random Access Memory (RAM) consists of billions of data cells, each data-cell uses a D-Type flip-flop circuit.

Digital Padlock

To create our padlock we will need a circuit to input a 3-bit combination and store it using 3 memory cells (D-Type Flip-Flop circuits).

We will then use another set of 3 inputs to let the user try to unlock the padlock by trying different combinations. You can click on the circuit below to access our full 3-bit digital padlock.

You will notice on this circuit that the 3 XNOR gates are used to compare each digit (user guess with combination). If both digits are the same (both set to 0 or both set to 1) the XNOR gate output is on. The AND gates are then used to check if all 3 digits have been guessed right. In this case the lightbulb will turn on, indicating that the user has found the correct combination/key.

To use this circuit you will need to complete the following 5 steps:

  1. Input a combination (e.g. 101) using the top 3 switches set to “On-Off-On”.
  2. Turn the enabler (Reset button) to “on” to store this combination into the memory cells.
  3. Turn the enabler (Reset button) to “off” to lock the combination.
  4. Hide the combination by turning all top 3 switches to “off”.
  5. Use the bottom 3 switches to try to guess the right combination. The bulb should only be on when the right combination is inputted (e.g. 101).

Your task

First you will need to test the above circuit with different combinations to see if it works. Then your task is to complete this circuit by adding an extra digit to the key and turn this padlock into a 4-bit padlock.



The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.6 / 5. Vote count: 9

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: