Membrane keypad 4×4
16 keys, 8 wires
A thin keypad with digits and letters. Used for codes (electronic lock), entering numbers and menus.
Open the course →How it works
16 keys would need 16 pins, but the keypad is a matrix: 4 rows and 4 columns. The program puts one row LOW, reads the 4 columns (with pull-ups), and if one is LOW it knows which key is pressed. Then the same for the next row, very fast. That way 8 pins read 16 keys. The Keypad library does the scanning.
Pins and wiring
| Pin | What it is | Where it connects / why |
|---|---|---|
| R1 – R4 | Rows (pins 1–4) | → 4 GPIO (outputs). |
| C1 – C4 | Columns (pins 5–8) | → 4 GPIO with pull-up (inputs). |
Specifications
Keys16 (0–9, A–D, *, #)
Wires8
Voltageup to 24 V, usually 3.3 V logic
Lifetime~1 million presses
Tips and typical mistakes
- Do not use GPIO 34–39 for the columns — they have no internal pull-up.
- If the keys are "shifted", your rows and columns are swapped in the code.