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.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* tutorial_4b_split_keyboard_with_shift_registers.ino
  2. Tested on Teensy LC and two 74HC165 shift registers.
  3. Controller Two shift registers daisy chained
  4. | Left |**0**| | Right |**0**|**1**|**2**|**3**|**4**|**5**|**6**|
  5. |:-----:|-----| |:-----:|-----|-----|-----|-----|-----|-----|-----|
  6. | **0** | x | | **0** | 0 | 1 | 2 | 3 | 4 | 5 | 6 |
  7. | **1** | y | | **1** | a | b | c | d | e | f | g |
  8. */
  9. // ################## GLOBAL ###################
  10. // ================= INCLUDES ==================
  11. #include <ScanDelay.h>
  12. #include <Code_Sc.h>
  13. //Left matrix
  14. #include <Scanner_uC.h>
  15. #include <Row.h>
  16. //Right matrix
  17. #include <Scanner_ShiftRegsPISOSingleRow.h>
  18. // =============== CONFIGURATION ===============
  19. ScanDelay scanDelay(9000);
  20. // =================== CODES ===================
  21. Code_Sc s_a(KEY_A);
  22. Code_Sc s_b(KEY_B);
  23. Code_Sc s_c(KEY_C);
  24. Code_Sc s_d(KEY_D);
  25. Code_Sc s_e(KEY_E);
  26. Code_Sc s_f(KEY_F);
  27. Code_Sc s_g(KEY_G);
  28. Code_Sc s_x(KEY_X);
  29. Code_Sc s_y(KEY_Y);
  30. Code_Sc s_0(KEY_0);
  31. Code_Sc s_1(KEY_1);
  32. Code_Sc s_2(KEY_2);
  33. Code_Sc s_3(KEY_3);
  34. Code_Sc s_4(KEY_4);
  35. Code_Sc s_5(KEY_5);
  36. Code_Sc s_6(KEY_6);
  37. // ================= SCANNERS ==================
  38. // --------------- LEFT SCANNER ----------------
  39. uint8_t readPins_L[] = {14};
  40. uint8_t readPinCount_L = sizeof(readPins_L)/sizeof(*readPins_L);
  41. Scanner_uC scanner_L(LOW, readPins_L, readPinCount_L); //active LOW
  42. /* --------------- RIGHT SCANNER ---------------
  43. use slaveSelect pin SS (Arduino pin 10) for fastest scan
  44. */
  45. Scanner_ShiftRegsPISOSingleRow scanner_R(HIGH, SS, 2); //active HIGH
  46. // =================== ROWS ====================
  47. // ----------------- LEFT ROWS -----------------
  48. Key* ptrsKeys_L0[] = { &s_x };
  49. uint8_t KEY_COUNT_L0 = sizeof(ptrsKeys_L0)/sizeof(*ptrsKeys_L0);
  50. Row row_L0(scanner_L, 0, ptrsKeys_L0, KEY_COUNT_L0);
  51. Key* ptrsKeys_L1[] = { &s_y };
  52. uint8_t KEY_COUNT_L1 = sizeof(ptrsKeys_L1)/sizeof(*ptrsKeys_L1);
  53. Row row_L1(scanner_L, 1, ptrsKeys_L1, KEY_COUNT_L1);
  54. // ----------------- RIGHT ROWS ----------------
  55. Key* ptrsKeys_R0[] = { &s_6, &s_5, &s_4, &s_3, //shift register on right
  56. &s_c, &s_d, &s_e, &s_f,
  57. &s_2, &s_1, &s_0, &s_g, //shift register on left
  58. &s_a, &s_b }; //unused input pins are grounded
  59. Row row_R0(scanner_R, 0, ptrsKeys_R0, sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0));
  60. // ################### MAIN ####################
  61. void setup()
  62. {
  63. Keyboard.begin();
  64. scanner_R.begin();
  65. }
  66. void loop()
  67. {
  68. //left matrix
  69. row_L0.process();
  70. row_L1.process();
  71. //right matrix
  72. row_R0.process();
  73. scanDelay.delay();
  74. }