Arduino and a numeric keypad

A keypad is a nice simple method of accepting user input into your project. These come in a number of styles and generally there are 2 types a 3×4 keypad and a 4×4 keypad. The numbers stand for the rows and columns, so a 3×4 keypad has 3 columns and 4 rows. These are simple to connect to your Arduino, in the example below we simply connect the 7 connections to 7 pins on our Arduino

Here is a picture of the keypad we purchased, we have a link to the exact one underneath. these are available from many online stores



The connection cannot be any more straightforward, here is the layout

arduino and keypad layout
arduino and keypad layout


Here is a basic schematic

arduino and keypad schematic
arduino and keypad schematic


The code example takes advantage of a Keypad library, you can download this from here. Extract and copy this to your Arduino libraries folder

In the example below the button pressed will then be displayed in the Serial monitor


#include “Keypad.h”

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup()

void loop()
char key = keypad.getKey();

if (key != NO_KEY){


Further experiments could be a password system, an alarm entry panel, a basic calculator etc


This was the exact keypad I ordered, only cost £0.99 for 1

4 x 3 Matrix 12 Key Array Membrane Switch Keypad Keyboard For Arduino

DC 4 Key Matrix Membrane Switch Control Keypad Keyboard

  • Facebook
  • Twitter
  • Linkedin
  • Pinterest


Comments are closed.

This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :