Creating a combination lock using logic gates?

I would probably use two bits to encode the three switches, and the general approach would be to have a string of pairs (one for each bit) of D or JK flip-flops to accept the sequence of input digits, essentially a shift register for pairs of bits. Then there would have to be de-bounce circuitry for the switches, and some way to generate a clock signal from the key presses (probably on release) to shift the digits through the register. Finally, XOR gates between the stages of the shift register and the digits of the key (hardwired to 1231 or use switches, etc) would produce signals to indicate when each digit is a correct match (logic Low on match), and then a multi-input NOR of the XOR outputs would give a final output signal that would indicate when the entire sequence in the shift register matches the key.


A long long time ago I made a 'combination' lock with one button. It used a shift register. A long button press would shift in a 0, a short one would shift in a 1. (I used some resistors and capacitors to do this, but there are more elegant ways). The outputs of the shift register were connected to two inhibit lines using diodes. To open the lock, one inhibit line had to be pulled high (by a resistor), the other low. The code was determined by how the diodes connectd to the inhibit lines.

At that time I lived in a caravan. No toilet inside the caravan. The door automatically fell into the lock when I closed it behind me. Without the electronic lock I would have to dig up the spare key burried behind the 7th tree every time I forgot to take the keys with me when I went for a nightly visit to the loo.