









The 3x4 keypad has 7 pins: 3 for rows and 4 for columns. The pinout may vary slightly depending on the manufacturer, so always refer to the specific datasheet for your keypad. Below is a general pin configuration:
| Pin | Name | Description |
|---|---|---|
| 1 | R1 | Row 1 (connect to GPIO pin) |
| 2 | R2 | Row 2 (connect to GPIO pin) |
| 3 | R3 | Row 3 (connect to GPIO pin) |
| 4 | C1 | Column 1 (connect to GPIO pin) |
| 5 | C2 | Column 2 (connect to GPIO pin) |
| 6 | C3 | Column 3 (connect to GPIO pin) |
| 7 | C4 | Column 4 (connect to GPIO pin) |
Below is an example of how to use a 3x4 keypad with an Arduino UNO using the Keypad Library:
#include <Keypad.h>
// Define the rows and columns of the keypad
const byte ROWS = 3; // 3 rows
const byte COLS = 4; // 4 columns
// Define the keymap for the keypad
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
// Define the row and column pins connected to the Arduino
byte rowPins[ROWS] = {2, 3, 4}; // Connect to R1, R2, R3
byte colPins[COLS] = {5, 6, 7, 8}; // Connect to C1, C2, C3, C4
// Create a Keypad object
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600); // Initialize serial communication
Serial.println("Keypad Test: Press a key");
}
void loop() {
char key = keypad.getKey(); // Check if a key is pressed
if (key) {
// Print the pressed key to the Serial Monitor
Serial.print("Key Pressed: ");
Serial.println(key);
}
}
No Key Press Detected:
Incorrect Key Presses:
Multiple Key Presses Detected:
Keypad Not Responding:
Can I use fewer GPIO pins with a 3x4 keypad? Yes, you can use a multiplexer or shift register to reduce the number of GPIO pins required.
Is the keypad waterproof? Most 3x4 keypads are not waterproof. If needed, look for a sealed or membrane keypad.
Can I use this keypad with a Raspberry Pi?
Yes, but you may need to use a Python library like pad4pi for easier integration.
How do I extend the keypad's cable length? Use shielded cables to reduce noise and interference over longer distances.