Random Nerd Tutorials

Arduino Membrane Keypad Tutorial


A keypad allows you to interact with a microcontroller. You can salvage these keypads from old telephones or you can purchase them from most electronics store for less than $2.

$_57They come in wide variety of shapes and sizes. The most commons sizes are 3×4 and 4×4 and you can get keypads with with words, letters and numbers written on the keys.

You can even create your own keypad from scratch.

If you follow this tutorial you can control any keypad.


These keypads very popular among the Arduino tinkerers. They are very cheap and you can use them with any microcontroller (MCU).

Where to buy?

You can purchase these modules for just a few dollars. Click here to compare the membrane keypad on several stores and find the best price.

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!


How it Works?

A membrane keypad is a matrix consisting of rows and columns. Each key is assigned to a certain row and column (see the picture below).

On a 12 button keypad you have 4 rows and 3 columns. The first key would make a link between Row 1 and Column 1 (R1C1). 2 would be R1C2, 3 R1C3, *  R4C1, 9 R3C3 and so on.

how it works - keypad

Arduino with Membrane Keypad

You need the following components to make this circuit:

  • 1x Arduino (eBay)
  • 1x Keypad (eBay)
  • Jumper Wires


Follow the next schematics. If your keypad is different from the one below, try to search for the datasheet online.

membrane keyboard arduin tutorial schematics


Library Download

Here’s the library you need for this project:

  1. Download the Keypad library
  2. Unzip the Keypad library
  3. Install the Keypad library in your Arduino IDE by moving the unzipped folder to: Arduino\Libraries
  4. Restart your Arduino IDE

Uploading the Code

If your keypad doesn’t work with code below you might have to change the connections from the previous schematics.

Search the web or go to the store that sold you the keypad to find the datasheet for your keypad.

Note: If your keypad has more keys you can change lines 3 and 4 to add the right number of rows and columns. Then in line 5 you can change the array to match your keypad keys.


In this project when you press a key, it’s displayed the value in your serial montior. Here’s what you should see in your Arduino IDE serial monitor when you start pressing the keypad keys.

serial monitor with arduino and keypad


Now you can create an interface for your Arduino using a keypad. You could also add an LCD to this project.

I hope you found this guide useful.

Share this post with a friend that also likes electronics!

You can contact me by leaving a comment. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.

MicroPython Programming with ESP32/ESP8266 eBook

Learn how to program the ESP boards with MicroPython, including projects, tips, and tricks! The registrations are open for a limited time, so SIGN UP NOW »

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our course even with no prior experience!

Leave a Comment:

Add Your Reply

⏰ Registrations are open for "MicroPython Programming with ESP32 and ESP8266" eBook