Papermind

keypad

Dec 28th, 2017
4,423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <Keypad.h>
  2. const byte ROWS = 4; //four rows
  3. const byte COLS = 4; //three columns
  4. char keys[ROWS][COLS] = {
  5.  
  6.   {'1','4','7','*'},
  7.   {'2','5','8','0'},
  8.   {'3','6','9','#'},
  9.   {'a','b','c','d'}
  10. };
  11. byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
  12. byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad
  13.  
  14. Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
  15.  
  16. void setup(){
  17.   Serial.begin(9600);
  18. }
  19.  
  20. void loop(){
  21.   char key = keypad.getKey();
  22.  
  23.   if (key){
  24.     Serial.println(key);
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment