Digital Lock Pick #2

[Part 1: Introduction] [Part 2: Keypads]

A whole month has passed since I posted my Digital Lock Pick Introduction, and I am pleased to report that it is going rather well.

I have successfully interfaced an Arduino with an off-the-shelf keypad and managed to turn off the alarm without physically pressing any buttons. The image below shows the first prototype.

Keypad Hacker

So then, Keypads. I’ve based all of my theory and design around the basic structure of the typical home electronics keypad, but that’s not as crazy as it sounds. In doing some digging, I’ve found that most keypads follow the same basic structure, and work in basically the same way. *Please note that all the images below illustrate theory work that I had done before I looked at a real keypad. In testing, I have found that, contrary to what I read, it is actually the Rows that are high, and not the columns. Regardless, the basic structure and plan of attack are more or less unaffected. (It took ages to make all the images below, and I can’t be bothered to do them again.)

They use a column and row structure that allows you to have, for example 16 keys, but use only 8 pins on the controller.

The following images show a not-completely-accurate-but-accurate-enough-for-illustrative-purposes representation of a matrix keypad.

In order for the controller to recognise which of the 16 buttons the user has pressed, we must do some deduction.

In this image we can see that all the columns are high and all the rows are low. *See note above.


When we press the button for digit 1, we connect column 1 to row 1, and this equals 1.


Likewise, when we press the button for digit 4, we connect column 1 to row 2, and this equals 4.


Continuing, connecting column 3 to row 1 gives us 3.


And Connecting column 4 to row 4 gives us D.


This seems to be the basic structure behind most keypads, and I can see why, it works quite efficiently. The complicated part comes when we try to press these buttons electronically, and not use 16 pins in the process.

There are multiple ways to do this, I have come up with two myself, but the way I am going to show you is my favourite, well, currently anyway.

We’re going to use AND gates, NOT gates and 6 Arduino pins. We will also need to use some optocouplers.

Once again, Logicly comes to the rescue.

Using 2 NOT gates, a 4-input AND gate and 3 Arduino Pins we can create a system that will allow us 4 levels of control over one of the digits on the keypad. The images below illustrate the circuit.

In this first image we see the system at rest. Latch 1 & 2 both come from the Arduino, as does Control Pin 1. Column 1 and Row 1 both come from the Keypad in the Wild.


Latch 1 and 2 are both connected to NOT gates. The output of NOT Gate 1 is connected to the first Input (1A) on the AND Gate. The Output from NOT Gate 2 is connected to 1B on the AND Gate. Our Arduino Control Pin is connected to 1C and column 1 from the Keypad in the Wild is connected to 1D. The output of the AND Gate is connected to row 1 from the keypad in the wild.

In this state, with Latch 1 and 2 both LOW, and the Control Pin LOW, nothing happens. If we make the Control Pin HIGH, all four inputs on the AND Gate are HIGH, and thus the AND Gate’s output goes HIGH.

So, making Control Pin 1 HIGH, connects Column 1 to Row 1.


In reality, we only really need 3-Input AND gates, but I ordered 4-Input, so we’ll use those. Also in reality, because we are using 4-Input ANDs, 1D is actually just connected to VCC to make it HIGH all the time. Further still, in reality, The output of the AND gate is actually connected to Pin 1 of an Optocoupler, Column 1 is connected to Pin 4 of the Opto and Row 1 is connected to Pin 5, but we’ll get into that later.

Like I said before there are 4 levels of control.

  • Latch 1 LOW, Latch 2 LOW.
  • Latch 1 LOW, Latch 2 HIGH.
  • Latch 1 HIGH, Latch 2 HIGH.
  • Latch 1 HIGH, Latch 2 LOW.

If we add three more NOT gates and three more AND gates, all of a sudden we can press digits 1, 4, 7 and *, and that would look like this:


Using three Arduino Pins we can control 4 rows on the keypad, we can press 4 buttons:

Latch 1 Latch 2 Control Pin 1 Result

This GIF illustrates the method.


Now all that is left to do, at least in the theory section, is scale it up.


That’s all for now. Next time we’ll look at some actual keypads, do some more math and look at my circuit board design.

[Part 1: Introduction] [Part 2: Keypads]

Author: Dan

Share This Post On