Advertisement
ArseniyCH

23. 4x4 Button to display the experimental routine (first)

Nov 22nd, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <Keypad.h>
  2. const byte ROWS = 4; // define four rows
  3. const byte COLS = 4; // define four
  4. char keys [ROWS] [COLS] = {
  5. {'1 ', '2', '3 ',' A '},
  6. {'4 ', '5', '6 ',' B '},
  7. {'7 ', '8', '9 ',' C '},
  8. {'*', '0 ',' # ',' D '}
  9. };
  10. // Connect 4 * 4 keypad row-bit port, the corresponding digital IO ports panel
  11. byte rowPins [ROWS] = {2,3,4,5};
  12. // Connect 4 * 4 buttons faithfully port, the corresponding digital IO ports panel
  13. byte colPins [COLS] = {6,7,8,9};
  14. // Call the function library function Keypad
  15. Keypad keypad = Keypad (makeKeymap (keys), rowPins, colPins, ROWS, COLS);
  16.  
  17. void setup()
  18. {
  19.   Serial.begin (9600);
  20. }
  21.  
  22. void loop()
  23. {
  24.   char key = keypad.getKey ();
  25.   if (key != NO_KEY)
  26.     Serial.println (key);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement