4×4 Keypad Matrix
Overview
A keypad matrix using digital pins. Supports keypads up to 4×4 size.


Supported GPIO
- Raspberry Pi 0~4
- Raspberry Pi 5
- BeagleBone Black/Green
- Jetson Nano
- FT232H, FT2232H, FT4232H
- MCP2221
- NUMATO USB-GPIO (8~128CH)
Commands
[INIT]
Enters initial configuration settings.
Item | Type | Description |
---|---|---|
Number of Rows | WRITE | Enter the number of rows in the keypad. |
Number of Columns | WRITE | Enter the number of columns in the keypad. |
Row 1 Characters | WRITE | Enter the characters for the first row of the keypad, separated by commas. (e.g., 1,2,3,A) |
Row 2 Characters | WRITE | Enter the characters for the second row of the keypad, separated by commas. (e.g., 4,5,6,B) |
Row 3 Characters | WRITE | Enter the characters for the third row of the keypad, separated by commas. (e.g., 7,8,9,C) |
Row 4 Characters | WRITE | Enter the characters for the fourth row of the keypad, separated by commas. (e.g., *,0,#,D) |
Row GPIO | WRITE | Enter the GPIO numbers connected to the row pins (R1,R2…) of the keypad, separated by commas. (e.g., 17,27,22,23) |
Column GPIO | WRITE | Enter the GPIO numbers connected to the column pins (C1,C2…) of the keypad, separated by commas. (e.g., 24,25,5,6) |
[GET_KEYS]
Checks whether each key on the keypad is pressed. No return value.
[GET_KEY]
Returns the character of the currently pressed key.
Item | Type | Description |
---|---|---|
Key Character | READ | Character of the currently pressed key. |
[IS_PRESSED]
Returns true if a specific key is pressed, false otherwise. The GET_KEYS command must be executed before using this command.
Item | Type | Description |
---|---|---|
Key Character | WRITE | Enter the character of the key to check for press status. |
Press Status | READ | True if the entered key is pressed, false otherwise. |
Example
Objective
Display the number of the currently pressed keypad key on dashboard widgets.
Parts
Part | Quantity |
---|---|
Raspberry Pi 4 * | 1 |
Keypad | 1 |
* Other hardware can also be used. Refer to Supported GPIO.
Wiring
Connect the following pins horizontally to each other.
4×4 Keypad | GPIO |
---|---|
R1 | 17 * |
R2 | 27 * |
R3 | 22 * |
R4 | 23 * |
C1 | 24 * |
C2 | 25 * |
C3 | 5 * |
C4 | 6 * |
* Any GPIO pins can be used.
