TPL-14Templates/Membrane Keypad
Membrane Keypad
4×4 membrane keypad (16 keys: 0–9, A–D, *, #) wired to 8 Arduino pins via row/column scanning. Requires the Keypad library. Press a key and its character prints to the Serial Monitor.
Open in Playgroundintermediate · keypad · input · serial · matrix · Keypad library
FIG. 1Membrane Keypad · circuitTPL-14
02Sketch
sketch.inoArduino C++
26 lines
// Membrane Keypad — print key to Serial Monitor
#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);
}
}03Components
- 01Arduino Uno
- 02Membrane Keypad (wokwi-membrane-keypad)
04Wiring
| Component pin | Arduino pin |
|---|---|
| R1 (Row 1) | Pin 9 |
| R2 (Row 2) | Pin 8 |
| R3 (Row 3) | Pin 7 |
| R4 (Row 4) | Pin 6 |
| C1 (Col 1) | Pin 5 |
| C2 (Col 2) | Pin 4 |
| C3 (Col 3) | Pin 3 |
| C4 (Col 4) | Pin 2 |
Ready when you are
Have a circuit in mind?
No hardware, no installs — a browser is enough.