Blog

Guide to 4×4 Matrix Keypad for Arduino

4×4 Matrix Keypad

16-Button Input Interface for Arduino and Microcontroller Projects

Introduction

The 4×4 matrix keypad is a compact input device with 16 buttons arranged in a grid. Using only 8 pins, it provides an efficient way to add multiple button inputs to Arduino, Raspberry Pi, and other microcontroller projects.


Key Features

⌨️ 16 Buttons

4 rows × 4 columns matrix configuration

🔢 Standard Layout

0-9 digits plus A,B,C,D,*,# symbols

Low Power

Only draws current during scanning

🔌 Simple Interface

8-pin connection (4 rows + 4 columns)

Technical Specifications

Operating Voltage 1.5V – 24V DC
Contact Resistance <100mΩ
Insulation Resistance >100MΩ
Life Expectancy 1,000,000 presses
Dimensions 80mm × 80mm × 10mm (typical)
Button Spacing 19mm × 19mm (standard)

Pin Configuration


Pin Function Arduino Connection
1 Row 1 D9
2 Row 2 D8
3 Row 3 D7
4 Row 4 D6
5 Column 1 D5
6 Column 2 D4
7 Column 3 D3
8 Column 4 D2
Note: Pin connections can be customized to any digital pins

Wiring with Arduino


Important: Always use INPUT_PULLUP mode for columns to avoid floating inputs

 

Library Setup

  1. Install the Keypad library by Mark Stanley and Alexander Brevig
  2. Include the library in your sketch:
  3. Configure the keypad layout:

     

Basic Keypad Example

 

Advanced Features

Password Entry

Keypad Events

Multi-key Press

Custom Keymaps

Troubleshooting

No Key Detection

  • Verify all connections are secure
  • Check row/column pin assignments
  • Ensure proper keymap configuration

Ghost Presses

  • Use INPUT_PULLUP for columns
  • Add 0.1μF capacitors between rows/cols and GND
  • Implement software debouncing

Multiple Keys Not Working

  • Check for short circuits between pins
  • Verify sufficient power supply
  • Test with different digital pins