Introduction: Arduino - 4x5 Matrix Keypad Example Code and Schematic

About: Hello world! I make simple & Advanced projects for people who want to learn programming and electronics. Most of my Instructables are about arduino and the wide range of sensors you can use with it. I make…

Hello world! Today i made a Example Code for the 4x5 matrix keypad.

I could not find any codes that were working or doing anything at all. So i made this example code for the 4x5 keypad.

You can let the buttons do anything! I just gave each button a function in the code, You can see what value is what key in the serial monitor.

Subscribe to my Youtube channel!

Follow the next step for the Schematic & Code & parts list!

Step 1: Schematic, Code & Parts List.

Parts list:

  • Arduino Mega! ( You need a mega!, Or you need to multiplex!)
  • 10x Leds.
  • 1x Buzzer.
  • Keypad 4x5 Matrix Keypad (very cheap on aliexpress)
  • 2x 1 channel relay
  • Jumper wires set MM/FF/MF

Just wire it up like the schematic. Here is little more info i grabbed from the internet about the 4x5 Keypad.


  • Row 1 to Arduino pin 2
  • Row 2 to Arduino pin 3
  • Row 3 to Arduino pin 4
  • Row 4 to Arduino pin 5
  • Row 5 to Arduino pin 6
  • Column A to Arduino pin 8
  • Column B to Arduino pin 9
  • Column C to Arduino pin 10
  • Column D to Arduino pin 11

Key values with connector at top.

  • 4 9 14 19
  • 3 8 13 18
  • 2 7 12 17
  • 1 6 11 16
  • 0 5 10 15

Connector (from left to right with keys facing up, connector at top):

Columns Rows


A B C D 1 2 3 4 5

(Rows link keys from left to right, columns link keys from top to bottom)

Good luck!

(NOTE! This instructable is just an example on how the keypad works! It does not really have a function other then turning on leds, a buzzer & relays.)

Go to our website to find some sensors!

Follow my Youtube channel!

Follow me on instructables!