keybrd library is an open source library for creating custom-keyboard firmware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

keybrd_4b_split_keyboard_with_shift_registers.ino 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* tutorial_4a_split_keyboard_with_shift_registers.ino
  2. Tested on Teensy LC and two 74HC165 shift registers.
  3. The right matrix has 2 shift registers daisy chained.
  4. Layout Layout
  5. | Left |**0** | Right |**0**|**1**|**2**|**3**|**4**|**5**|**6**|**7**|
  6. |:-----:|-----| |:-----:|-----|-----|-----|-----|-----|-----|-----|-----|
  7. | **0** | x | | **0** | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  8. | **1** | y | | **1** | a | b | c | d | e | f | g | h |
  9. */
  10. // ################## GLOBAL ###################
  11. // ================= INCLUDES ==================
  12. #include <ScanDelay.h>
  13. #include <Code_Sc.h>
  14. //Left matrix
  15. #include <Row_uC.h>
  16. //Right matrix
  17. #include <SPI.h>
  18. #include <Row_ShiftRegisters.h>
  19. // =============== CONFIGURATION ===============
  20. ScanDelay scanDelay(9000);
  21. // =================== CODES ===================
  22. Code_Sc s_a(KEY_A);
  23. Code_Sc s_b(KEY_B);
  24. Code_Sc s_c(KEY_C);
  25. Code_Sc s_d(KEY_D);
  26. Code_Sc s_e(KEY_E);
  27. Code_Sc s_f(KEY_F);
  28. Code_Sc s_g(KEY_G);
  29. Code_Sc s_x(KEY_X);
  30. Code_Sc s_y(KEY_Y);
  31. Code_Sc s_0(KEY_0);
  32. Code_Sc s_1(KEY_1);
  33. Code_Sc s_2(KEY_2);
  34. Code_Sc s_3(KEY_3);
  35. Code_Sc s_4(KEY_4);
  36. Code_Sc s_5(KEY_5);
  37. Code_Sc s_6(KEY_6);
  38. // =============== LEFT MATRIX =================
  39. //set left matrix for active low
  40. const bool Scanner_uC::STROBE_ON = LOW;
  41. const bool Scanner_uC::STROBE_OFF = HIGH;
  42. //column pin
  43. uint8_t readPins[] = {14};
  44. uint8_t READ_PIN_COUNT = sizeof(readPins)/sizeof(*readPins);
  45. //rows
  46. Key* ptrsKeys_L0[] = { &s_x };
  47. Row_uC row_L0(0, readPins, READ_PIN_COUNT, ptrsKeys_L0);
  48. Key* ptrsKeys_L1[] = { &s_y };
  49. Row_uC row_L1(1, readPins, READ_PIN_COUNT, ptrsKeys_L1);
  50. // =============== RIGHT MATRIX ================
  51. //set matrix to active high
  52. const bool Scanner_ShiftRegs74HC165::STROBE_ON = HIGH;
  53. const bool Scanner_ShiftRegs74HC165::STROBE_OFF = LOW;
  54. //chip select pin
  55. const uint8_t Scanner_ShiftRegs74HC165::SHIFT_LOAD = 10;
  56. //rows
  57. Key* ptrsKeys_R0[] = { &s_6, &s_5, &s_4, &s_3, //shift regiser on right
  58. &s_c, &s_d, &s_e, &s_f,
  59. &s_2, &s_1, &s_0, &s_g, //shift regiser on left
  60. &s_a, &s_b }; //unused input pins are grounded
  61. Row_ShiftRegisters row_R0(0, sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0), ptrsKeys_R0);
  62. // ################### MAIN ####################
  63. void setup()
  64. {
  65. Keyboard.begin();
  66. SPI.begin();
  67. row_R0.begin();
  68. }
  69. void loop()
  70. {
  71. //left matrix
  72. row_L0.process();
  73. row_L1.process();
  74. //right matrix
  75. row_R0.process();
  76. scanDelay.delay();
  77. }