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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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_ShiftRegsRead.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. Scanner_ShiftRegsRead scanner_R(HIGH, 10, 2); //active HIGH
  44. // =================== ROWS ====================
  45. // ----------------- LEFT ROWS -----------------
  46. Key* ptrsKeys_L0[] = { &s_x };
  47. uint8_t KEY_COUNT_L0 = sizeof(ptrsKeys_L0)/sizeof(*ptrsKeys_L0);
  48. Row row_L0(scanner_L, 0, ptrsKeys_L0, KEY_COUNT_L0);
  49. Key* ptrsKeys_L1[] = { &s_y };
  50. uint8_t KEY_COUNT_L1 = sizeof(ptrsKeys_L1)/sizeof(*ptrsKeys_L1);
  51. Row row_L1(scanner_L, 1, ptrsKeys_L1, KEY_COUNT_L1);
  52. // ----------------- RIGHT ROWS ----------------
  53. Key* ptrsKeys_R0[] = { &s_6, &s_5, &s_4, &s_3, //shift register on right
  54. &s_c, &s_d, &s_e, &s_f,
  55. &s_2, &s_1, &s_0, &s_g, //shift register on left
  56. &s_a, &s_b
  57. }; //unused input pins are grounded
  58. Row row_R0(scanner_R, 0, ptrsKeys_R0, sizeof(ptrsKeys_R0)/sizeof(*ptrsKeys_R0));
  59. // ################### MAIN ####################
  60. void setup()
  61. {
  62. scanner_R.begin();
  63. }
  64. void loop()
  65. {
  66. //left matrix
  67. row_L0.process();
  68. row_L1.process();
  69. //right matrix
  70. row_R0.process();
  71. scanDelay.delay();
  72. }