What You Need for a Keypad Entry System Arduino Project - dummies

What You Need for a Keypad Entry System Arduino Project

By Brock Craft

No self-respecting mastermind would leave his fortress unsecured against intruders. These Arduino project steps guide you through building a keypad entry system that unlocks a door when you enter the correct code into a standard 10-digit keypad. The system also displays the code on a seven-segment LED display while you are entering it, and when you’ve keyed in the correct code a welcome message is displayed.

You create a prototype on a breadboard to make sure that everything works properly and then put it into a suitable enclosure after it’s working. When you transfer it to your enclosure, you might want to rebuild the circuit on a piece of stripboard. There are a lot of wires in this project, so you might also want to pick up some ribbon cable to make all those connections.

Here’s what you need:

  • An Arduino

  • A numeric keypad (SparkFun COM-08653 or Rapid 78-0305)

  • A quad, common cathode, seven-segment LCD display (Lite-ON LTC-4727JR from Digi-Key 160-1551-5ND, or HDSP-B09G from Farnell 1003341)

  • A Max 7219 or 7221 8-digit LED display driver

  • Two capacitors: a 10µF (microfarad) electrolytic capacitor and a .01 µF ceramic disc capacitor

  • Two resistors: 2.2kΩ and 33kΩ. These may be different depending on your LED module and type of relay.

  • A 5V DC miniature relay (such as Hamlin HE721A0510, from Jameco #1860109, or Farnell #9561757)

  • A 2N2222 or similar NPN transistor

  • A 1N4001 or similar diode

  • A strip of pin headers

  • An electric door locking mechanism, 12V DC. There are several types (see below) to choose from, such as an electric door strike (item #5192 from SmartHome.com or GAE Series Electric Strike from onlinesecurityproducts.co.uk).

  • A two-conductor, low-voltage wire (18-22 AWG) to run power from your transformer to your project box and door locking mechanism.

  • A suitable enclosure to package it up nicely (such as Serpac A27BK, Jameco #373456, or Farnell #775538). Minimum dimensions of approximately 6 x 3 x 1.5 inches (15 x8 x 4 cm).

  • A small piece of stripboard (optional)

  • Some short lengths of ribbon cable (optional)

  • Wire mounting clips

  • A hot glue gun and some glue sticks

  • A measuring tape

  • Small hand tools to make holes in the enclosure and to install the door locking mechanism into your doorjamb.


The keypad contains conductive traces on the printed circuit board inside. Pressing a button closes a switch that connects two of these traces. Each row and column is connected to an output pin on the keypad, and you connect those output pins to your Arduino’s digital pins. When you press a button, the connection between a row and a column is made.

Manufacturers assign different keypad output pins to the rows and columns. Two of the commonly available keypads are listed previously and are used in the sample code. If your keypad is different, you’ll need to test it or read the keypad’s datasheet to determine how to connect your keypad’s output pins to your Arduino’s digital pins.


The power supply should be rated at 12V DC. Most electronic lock mechanisms are available in 12V DC models and this is an acceptable input for your Arduino. Also, make sure your transformer will supply enough current to handle the needs of both your Arduino and your electronic lock. Your Arduino can operate at a bare minimum of 250mA, but it is safer to estimate it at 500mA.

The spec sheet of your lock mechanism should say how much current is required to operate it. If not, you can use your multimeter to measure the current flowing through the coil of your lock, while it is activated. The GAE electronic door strike in the parts list operates at 12V DC at 400mA.

Combined with the Arduino, that’s a current requirement of 950mA. You should exceed this by a small margin, so that means your power must supply a minimum output of 1.0A. You can use one with a higher rating, but not a lower rating.

The display is a four-digit, seven-segment display of the type that you’ve seen just about everywhere. Using a quad display is a bit simpler than using four individual seven-segment displays. It has shared cathodes to reduce the number of pins needed to drive it. The cathodes and anodes for the digits and the colon/decimal points are connected to just a few pins on the back of the unit.

Again, different manufacturers use different pinouts. The datasheet shows which pins are connected to each segment. You can use a different module than the ones listed here, but make sure you are using a common cathode (CC) display. A common anode (CA) display won’t work.

The display is driven by the Maxim 7219 or 7221 display driver (72xx, for short). This integrated circuit (or IC ) makes it very easy to control up to eight digits. It handles addressing each segment, storing the state of each digit, and even controlling the brightness through pulse-width modulation (PWM).

Conveniently, you send commands using the Serial Peripheral Interface (SPI) Arduino library. The chip requires only one resistor to set the LED current and two capacitors, which keep power fluctuations from harming it.

Best of all, it only uses three Arduino digital pins.

The lock mechanism is controlled by a relay. Turning on the relay allows power to flow from the power supply to the electric door lock. The switching transistor, resistor, and diode control the relay. The transistor is a 2n2222 general purpose NPN switching transistor. The 2.2KΩ resistor used with it prevents too much current flowing to the base of the transistor.

The diode prevents blowback, or back voltage, a phenomenon that occurs when power to the relay coil is switched off and its magnetic field breaks down.