Index
Introduction
The 4×4 Membrane Keypad is a simple user interface device with 16 keys arranged in 4 rows and 4 columns.
Each key press connects a unique row-column pair, which the ESP32-S3 can detect using digital input pins.
It’s ideal for projects requiring password input, menu navigation, or number entry.
In this tutorial, we’ll learn how to connect the 4×4 keypad to an ESP32-S3 and read key presses using the Arduino IDE.
Required Components
- ESP32-S3 Board
- 4×4 Keypad
- Jumper wires
- Breadboard (optional)
Pinout

Circuit Diagram / Wiring
- Keypad Column 4 → 34 (ESP32-S3)
- Keypad Column 3 → 35 (ESP32-S3)
- Keypad Column 2 → 32 (ESP32-S3)
- Keypad Column 1 → 33 (ESP32-S3)
- Keypad Row 4 → 25 (ESP32-S3)
- Keypad Row 3 → 26 (ESP32-S3)
- Keypad Row 2 → 27 (ESP32-S3)
- Keypad Row 1 → 14 (ESP32-S3)
Code / Programming
- Install Required Library (via Arduino Library Manager).
- Go to the “Libraries” tab on the left-hand side of the screen.
- Click on the “Library Manager” button (book icon) at the top of the Libraries tab.
- In the Library Manager window, type “Keypad” in the search bar.
- Locate the “Keypad” library click on the “Install” button next to it.
- Wait for the library to be installed, and you’re ready to use the Keypad library in your projects.

/*
Filename: ESP32-S3_keypad_input.ino
Description: Reads input from a 4x4 keypad and prints pressed keys to the Serial Monitor
Author: www.oceanlabz.in
Modification: 1/4/2025
*/
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {14, 27, 26, 25}; // Connect to R1-R4
byte colPins[COLS] = {33, 32, 35, 34}; // Connect to C1-C4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(115200);
}
void loop() {
char key = keypad.getKey();
if (key) {
Serial.print("Key Pressed: ");
Serial.println(key);
}
}
Explanation
- A 4×4 keypad has 16 keys arranged in a matrix of 4 rows and 4 columns.
- Each key press connects a specific row and column, which the ESP32-S3 detects using digital I/O pins.
- The
Keypad
library scans the matrix and returns the character of the pressed key.
Troubleshooting
- Ensure keypad pins are connected in the correct row/column order to the ESP32-S3.
- Avoid using boot-related GPIOs like GPIO0, GPIO2, or GPIO15 for keypad connections.
- If no key press is detected, check for loose wires, incorrect wiring, or wrong pin numbers in code.