3x4 Keypad Example

Libraries used

GitHub - Chris–A/Keypad: A version of the keypad library found in Wiring. This is just a copy made compatible with the Arduino IDE library manager.
Or you can install from library manager

Code

Based off Keypad/examples/CustomKeypad/CustomKeypad.ino at master · Chris–A/Keypad · GitHub

#include <Keypad.h>

const byte ROWS = 4; 
const byte COLS = 3; 
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};
byte rowPins[ROWS] = {53,52,51,50}; 
byte colPins[COLS] = {49, 48, 47}; 

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char customKey = customKeypad.getKey();
  
  if (customKey){
    Serial.println(customKey);
  }
}

Demo of working

1 Like