Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <Keypad.h>
  2.  
  3. const byte ROWS = 4; //four rows
  4. const byte COLS = 4; //four columns
  5. //define the Symbols on the buttons of the keypads
  6. char hexaKeys[ROWS][COLS] = {
  7.   {'1','2','3','A'},
  8.   {'4','5','6','B'},
  9.   {'7','8','9','C'},
  10.   {'Y','0','N','S'}
  11. };
  12. byte rowPins[ROWS] = {7, 8, 9, 10}; //connect to the row pinouts of the keypad
  13. byte colPins[COLS] = {6, 5, 4, 3}; //connect to the column pinouts of the keypad
  14. //initialize an instance of class NewKeypad
  15. Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
  16.  
  17. char code[9];
  18. int code_x=0;
  19.  
  20. void printCode() {
  21.   for(int x=0; x=8; x++) {
  22.     Serial.print(code[x]);
  23.   }
  24. }
  25.  
  26. void setup(){
  27.   Serial.begin(9600);
  28. }
  29.  
  30. void loop(){
  31.   char customKey = customKeypad.getKey();
  32.   if (customKey=="N"){
  33.     Serial.println(customKey);
  34.     code_x=0;
  35.   }
  36.   else if (customKey=="Y") {
  37.     Serial.println(customKey);
  38.     Serial.println("invio codice...");
  39.     printCode();
  40.   }
  41.   else if (customKey) {
  42.     Serial.println(customKey);
  43.     code[code_x]=customKey;
  44.     code_x++;
  45.     printCode();
  46.     if (code_x=9) {
  47.       code_x=0;
  48.     }
  49.   }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement