harshsin

Untitled

Dec 30th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <Keypad.h>
  2. char A = '(1,1)'
  3. const byte ROWS = 3; // Four rows
  4. const byte COLS = 3; // Three columns
  5. // Define the Keymap
  6. char keys[ROWS][COLS] = {
  7.   {A,'2','3'},
  8.   {'4','5','6'},
  9.   {'7','8','9'}
  10. };
  11. // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
  12. byte rowPins[ROWS] = { 7,6,5};
  13. // Connect keypad COL0, COL1 and COL2 to these Arduino pins.
  14. byte colPins[COLS] = { 2, 3, 4 };
  15.  
  16. // Create the Keypad
  17. Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
  18.  
  19. #define ledpin 13
  20.  
  21. void setup()
  22. {
  23.   pinMode(ledpin,OUTPUT);
  24.   digitalWrite(ledpin, HIGH);
  25.   Serial.begin(9600);
  26. }
  27.  
  28. void loop()
  29. {
  30.   char key = kpd.getKey();
  31.   if(key)  // Check for a valid key.
  32.   {
  33.     Serial.println(key);
  34.   }
  35. }
Add Comment
Please, Sign In to add comment