PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

69 lines
1.6KB

  1. #include <Keypad.h>
  2. const byte ROWS = 2; // use 4X4 keypad for both instances
  3. const byte COLS = 2;
  4. char keys[ROWS][COLS] = {
  5. {'1','2'},
  6. {'3','4'}
  7. };
  8. byte rowPins[ROWS] = {5, 4}; //connect to the row pinouts of the keypad
  9. byte colPins[COLS] = {7, 6}; //connect to the column pinouts of the keypad
  10. Keypad kpd( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
  11. const byte ROWSR = 2;
  12. const byte COLSR = 2;
  13. char keysR[ROWSR][COLSR] = {
  14. {'a','b'},
  15. {'c','d'}
  16. };
  17. byte rowPinsR[ROWSR] = {3, 2}; //connect to the row pinouts of the keypad
  18. byte colPinsR[COLSR] = {7, 6}; //connect to the column pinouts of the keypad
  19. Keypad kpdR( makeKeymap(keysR), rowPinsR, colPinsR, ROWSR, COLSR );
  20. const byte ROWSUR = 4;
  21. const byte COLSUR = 1;
  22. char keysUR[ROWSUR][COLSUR] = {
  23. {'M'},
  24. {'A'},
  25. {'R'},
  26. {'K'}
  27. };
  28. // Digitran keypad, bit numbers of PCF8574 i/o port
  29. byte rowPinsUR[ROWSUR] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
  30. byte colPinsUR[COLSUR] = {8}; //connect to the column pinouts of the keypad
  31. Keypad kpdUR( makeKeymap(keysUR), rowPinsUR, colPinsUR, ROWSUR, COLSUR );
  32. void setup(){
  33. // Wire.begin( );
  34. kpdUR.begin( makeKeymap(keysUR) );
  35. kpdR.begin( makeKeymap(keysR) );
  36. kpd.begin( makeKeymap(keys) );
  37. Serial.begin(9600);
  38. Serial.println( "start" );
  39. }
  40. //byte alternate = false;
  41. char key, keyR, keyUR;
  42. void loop(){
  43. // alternate = !alternate;
  44. key = kpd.getKey( );
  45. keyUR = kpdUR.getKey( );
  46. keyR = kpdR.getKey( );
  47. if (key){
  48. Serial.println(key);
  49. }
  50. if( keyR ) {
  51. Serial.println( keyR );
  52. }
  53. if( keyUR ) {
  54. Serial.println( keyUR );
  55. }
  56. }