arduinoprojects

git clone https://git.tarina.org/arduinoprojects
Log | Files | Refs

CustomKeypad.ino (894B)


      1 /* @file CustomKeypad.pde
      2 || @version 1.0
      3 || @author Alexander Brevig
      4 || @contact alexanderbrevig@gmail.com
      5 ||
      6 || @description
      7 || | Demonstrates changing the keypad size and key values.
      8 || #
      9 */
     10 #include <Keypad.h>
     11 
     12 const byte ROWS = 4; //four rows
     13 const byte COLS = 4; //four columns
     14 //define the cymbols on the buttons of the keypads
     15 char hexaKeys[ROWS][COLS] = {
     16   {'0','1','2','3'},
     17   {'4','5','6','7'},
     18   {'8','9','A','B'},
     19   {'C','D','E','F'}
     20 };
     21 byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
     22 byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad
     23 
     24 //initialize an instance of class NewKeypad
     25 Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 
     26 
     27 void setup(){
     28   Serial.begin(9600);
     29 }
     30   
     31 void loop(){
     32   char customKey = customKeypad.getKey();
     33   
     34   if (customKey){
     35     Serial.println(customKey);
     36   }
     37 }