4×4 Matrix Keypad Module User’s Guide

1. Overview
The 4×4 Matrix Keypad is a simple input device with 16 keys arranged in 4 rows and 4 columns. It’s commonly used in embedded systems for entering numeric or alphanumeric data (e.g., PIN codes, menu navigation, calculator-style input).
- Keys:
0–9,A–D,*,# - Interface: 8-pin connector (4 rows + 4 columns). The other 2-pins at the edges are just ground guards.
- Typical use cases: Security panels, DIY electronics, calculators, menu-driven projects.
2. Pinout
The keypad has 8 pins that correspond to the rows and columns:
| Pin | Function | Notes |
|---|---|---|
| 1–4 | Row lines (R1–R4) | Activated when a button in that row is pressed |
| 5–8 | Column lines (C1–C4) | Used to detect which column the pressed button belongs to |
Exact pin order may vary by manufacturer, so check with a multimeter if needed.
3. How It Works
- Each key connects a row line to a column line when pressed.
- The microcontroller scans rows and columns to detect which key is pressed.
- Example: Pressing
5connects Row 2 to Column 2.
4. Wiring to Arduino UNO (Example)
Keypad Pin → Arduino Pin
R1 → D2
R2 → D3
R3 → D4
R4 → D5
C1 → D6
C2 → D7
C3 → D8
C4 → D9
5. Arduino Code Example
#include <Keypad.h>
const byte ROWS = 4; // four rows
const byte COLS = 4; // four columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; // connect to R1–R4
byte colPins[COLS] = {6, 7, 8, 9}; // connect to C1–C4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.println(key);
}
}
6. Applications
- Security systems: PIN entry for locks or alarms
- Menu navigation: Selecting options on LCD displays
- Calculators: Numeric input for math operations
- DIY controllers: Custom input devices for projects
7. Tips & Best Practices
- Use debouncing (handled by the Keypad library).
- Keep wires short to avoid signal noise.
- If using with ESP32/ESP8266, adjust pin assignments carefully (some pins are reserved).
- For durability, mount the keypad on a panel or enclosure.