Advertisement
Braulio777

4x4 Keypad For Arduino

Mar 20th, 2014
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. //Using 4x4-Keypad With Serial Monitor
  2.  
  3. #include <Keypad.h>
  4. const byte ROWS = 4;
  5. const byte  COLS = 4;
  6. char keys [ROWS] [COLS] =
  7. { {'1', '2', '3', 'A' },
  8.    {'4', '5', '6', 'B' },
  9.    {'7', '8', '9', 'C' },
  10.    {'*', '0', '#', 'D' } };
  11. byte rowPins [ROWS] = {2, 3, 4, 5};
  12. byte colPins [COLS] = {6, 7, 8, 9};
  13. Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
  14.  
  15. void setup( )
  16. {
  17. Serial.begin(9600);
  18. }
  19.  
  20. void loop( )
  21. {
  22. char key = keypad.getKey( );
  23.  if (key != NO_KEY)
  24. {
  25. Serial.print(key);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement