/* @file CustomKeypad.pde
  || @version 1.0
  || @author Alexander Brevig
  || @contact alexanderbrevig@gmail.com
  ||
  || @description
  || | Demonstrates changing the keypad size and key values.
  || #
  */
 #include <Keypad.h>

 #define ledPin 13

 //define the symbols on the buttons of the keypads
 char hexaKeys[4][5] = {
   "0123",
   "4567",
   "89AB",
   "CDEF"
 };

 // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these pins
 // eg. ROW0 = Arduino pin 8.
 byte rowPins[] = { 8, 7, 6, 5 };

 // Connect keypad COL0, COL1, COL2 and COL3 to these pins
 // eg. COL0 = Arduino pin 12.
 byte colPins[] = { 12, 11, 10, 9 };

 // Initialize an instance of class NewKeypad
 Keypad customKeypad = Keypad(hexaKeys, rowPins, colPins, sizeof(rowPins), sizeof(colPins));

 void setup()
 {
   digitalWrite(ledPin, HIGH);
   Serial.begin(9600);
 }

 void loop(){
   char customKey = customKeypad.getKey();

   if (customKey) {    // same as if(customKey != NO_KEY)
     Serial.println(customKey);
   }
 }

Share