Misc files
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.

PolyPad_ProMicro.ino 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. Copyright (c) 2014-2015 NicoHood
  3. See the readme for credit to other people.
  4. */
  5. #include "HID-Project.h"
  6. const int pinLed = LED_BUILTIN;
  7. const int MX01 = 2;
  8. const int MX02 = 3;
  9. const int MX03 = 4;
  10. const int MX04 = 5;
  11. const int MX05 = 7;
  12. const int MX06 = 8;
  13. const int MX07 = 21;
  14. const int MX08 = 20;
  15. const int MX09 = 19;
  16. const int MX10 = 18;
  17. const int MX11 = 14;
  18. const int MX12 = 16;
  19. const int VGround = 6;
  20. void setup() {
  21. // Prepare led + buttons
  22. pinMode(pinLed, OUTPUT);
  23. pinMode(MX01, INPUT_PULLUP);
  24. pinMode(MX02, INPUT_PULLUP);
  25. pinMode(MX03, INPUT_PULLUP);
  26. pinMode(MX04, INPUT_PULLUP);
  27. pinMode(MX05, INPUT_PULLUP);
  28. pinMode(MX06, INPUT_PULLUP);
  29. pinMode(MX07, INPUT_PULLUP);
  30. pinMode(MX08, INPUT_PULLUP);
  31. pinMode(MX09, INPUT_PULLUP);
  32. pinMode(MX10, INPUT_PULLUP);
  33. pinMode(MX11, INPUT_PULLUP);
  34. pinMode(MX12, INPUT_PULLUP);
  35. pinMode(VGround, OUTPUT);
  36. digitalWrite(VGround, LOW);
  37. // Sends a clean report to the host. This is important on any Arduino type.
  38. Keyboard.begin();
  39. }
  40. void loop() {
  41. if (!digitalRead(MX01)) {
  42. digitalWrite(pinLed, HIGH);
  43. Keyboard.write(KEY_HOME);
  44. // Simple debounce
  45. delay(300);
  46. digitalWrite(pinLed, LOW);
  47. }
  48. if (!digitalRead(MX02)) {
  49. digitalWrite(pinLed, HIGH);
  50. Keyboard.write(KEY_UP);
  51. // Simple debounce
  52. delay(300);
  53. digitalWrite(pinLed, LOW);
  54. }
  55. if (!digitalRead(MX03)) {
  56. digitalWrite(pinLed, HIGH);
  57. Keyboard.write(KEY_PAGE_UP);
  58. // Simple debounce
  59. delay(300);
  60. digitalWrite(pinLed, LOW);
  61. }
  62. if (!digitalRead(MX04)) {
  63. digitalWrite(pinLed, HIGH);
  64. Keyboard.write(KEY_LEFT);
  65. // Simple debounce
  66. delay(300);
  67. digitalWrite(pinLed, LOW);
  68. }
  69. if (!digitalRead(MX05)) {
  70. digitalWrite(pinLed, HIGH);
  71. Keyboard.write(KEY_ESC);
  72. // Simple debounce
  73. delay(300);
  74. digitalWrite(pinLed, LOW);
  75. }
  76. if (!digitalRead(MX06)) {
  77. digitalWrite(pinLed, HIGH);
  78. Keyboard.write(KEY_RIGHT);
  79. // Simple debounce
  80. delay(300);
  81. digitalWrite(pinLed, LOW);
  82. }
  83. if (!digitalRead(MX07)) {
  84. digitalWrite(pinLed, HIGH);
  85. Keyboard.write(KEY_END);
  86. // Simple debounce
  87. delay(300);
  88. digitalWrite(pinLed, LOW);
  89. }
  90. if (!digitalRead(MX08)) {
  91. digitalWrite(pinLed, HIGH);
  92. Keyboard.write(KEY_DOWN);
  93. // Simple debounce
  94. delay(300);
  95. digitalWrite(pinLed, LOW);
  96. }
  97. if (!digitalRead(MX09)) {
  98. digitalWrite(pinLed, HIGH);
  99. Keyboard.write(KEY_PAGE_DOWN);
  100. // Simple debounce
  101. delay(300);
  102. digitalWrite(pinLed, LOW);
  103. }
  104. if (!digitalRead(MX10)) {
  105. digitalWrite(pinLed, HIGH);
  106. Keyboard.write(KEY_BACKSPACE);
  107. // Simple debounce
  108. delay(300);
  109. digitalWrite(pinLed, LOW);
  110. }
  111. if (!digitalRead(MX11)) {
  112. digitalWrite(pinLed, HIGH);
  113. Keyboard.write(KEY_SPACE);
  114. // Simple debounce
  115. delay(300);
  116. digitalWrite(pinLed, LOW);
  117. }
  118. if (!digitalRead(MX12)) {
  119. digitalWrite(pinLed, HIGH);
  120. Keyboard.write(KEY_ENTER);
  121. // Simple debounce
  122. delay(300);
  123. digitalWrite(pinLed, LOW);
  124. }
  125. }