Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2. WWW.SANTY.CZ
  3. Díl 10 - klávesnice 4x4
  4. konektor 8 pinů
  5. */
  6. #include <Keypad.h> //připojíme knihovnu
  7.  
  8. const byte ROWS = 4; // 4 řádky
  9. const byte COLS = 4; // 4 sloupce
  10.  
  11. // zde si napíšete jak Vaše
  12. // membránová klávesnice vypadá
  13. char hexaKeys[ROWS][COLS] = {
  14.   {'1','2','3','A'},
  15.   {'4','5','6','B'},
  16.   {'7','8','9','C'},
  17.   {'*','0','#','D'}
  18. };
  19. byte rowPins[ROWS] = {9, 8, 7, 6}; //čísla pinů s řadkem 1 2 3 4
  20. byte colPins[COLS] = {5, 4, 3, 2}; //čísla pinu se sloupcem 1 2 3 4
  21.  
  22. //inicializuje objekt klávesnice s názvem customKeypad
  23. Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
  24.  
  25. void setup(){
  26.   Serial.begin(57600);
  27. }
  28.  
  29. void loop(){
  30.   // přečte znak z klávesnice
  31.   char customKey = customKeypad.getKey();
  32.  
  33.   // když není customKey null tak pošli znak na Serial port
  34.   if (customKey){
  35.     Serial.println(customKey);
  36.   }
  37. }