Membrane Keypad Reference
A 4×4 membrane keypad with 16 keys (0–9, A–D, *, #), scanned via 4 row and 4
column lines.
Pin names
| Name | Description |
|---|---|
| R1–R4 | Row lines |
| C1–C4 | Column lines |
Attributes
This component has no configurable attributes.
Usage
Connect each row and column pin to a separate GPIO — no resistors needed. Scan the matrix with the Keypad library, which handles debouncing and key mapping.
#include <Keypad.h>
const byte ROWS = 4, COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.print("Key: ");
Serial.println(key);
}
}
Examples
| Description | Attrs |
|---|---|
| Default 4×4 keypad | {} |
See also
- Pushbutton — single-key alternative for simpler input
- DIP Switch 8 — fixed 8-bit input instead of a scanned matrix