mc_workshop

DID keypad

May 16th, 2021
511
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   Keypad test
  3.   July 2020 by MC Workshop.
  4.   This example code is in the public domain.
  5. */
  6. #include <Keypad.h>
  7. const byte ROWS = 4; //righe
  8. const byte COLS = 4; //colonne
  9. //definizione dei simboli della tastiera
  10. char hexaKeys[ROWS][COLS] = {
  11.   {'1','2','3','A'},
  12.   {'4','5','6','B'},
  13.   {'7','8','9','C'},
  14.   {'*','0','#','D'}
  15. };
  16. byte rowPins[ROWS] = {9, 8, 7, 6}; //connessione Arduino
  17. byte colPins[COLS] = {5, 4, 3, 2}; //connessione Arduino
  18.  
  19. //inizializzazione istanza della classe
  20. Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
  21. void setup(){
  22.   Serial.begin(9600);
  23. }  
  24. void loop(){
  25.   char customKey = customKeypad.getKey();
  26.   if (customKey){
  27.     Serial.println(customKey);
  28.   }
  29. }
RAW Paste Data