Advertisement
Androxilogin

Jakks Games Controller

Feb 26th, 2023 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include "Keyboard.h" //include the library used for keyboard commands
  2. void setup() {
  3. delay(5000);
  4. pinMode(3, INPUT_PULLUP); //define all pins used as inputs
  5. pinMode(4, INPUT_PULLUP);
  6. pinMode(5, INPUT_PULLUP);
  7. pinMode(6, INPUT_PULLUP);
  8. pinMode(7, INPUT_PULLUP);
  9. pinMode(8, INPUT_PULLUP);
  10. pinMode(9, INPUT_PULLUP);
  11. Keyboard.begin();
  12. }
  13.  
  14. void loop() {
  15. int Fire = digitalRead(3); //define Fire as read pin 3
  16. int Up = digitalRead(4); //define Up as read pin 4
  17. int Down = digitalRead(5); //define Down as read pin 5
  18. int Right = digitalRead(6); //define Right as read pin 6
  19. int Left = digitalRead(7); //define Left as read pin 7
  20. int Reset = digitalRead(8); //define Reset as read pin 8
  21. int Pause = digitalRead(9); //define Pause as read pin 9
  22.  
  23. if (Fire == LOW)
  24. {
  25. Keyboard.press('z'); // If fire key (which is pin 3) goes low to press key 32 (spacebar)
  26. }
  27. if (Fire == HIGH)
  28. {
  29. Keyboard.release('z'); // If fire key (which is pin 3) goes high to release key 32 (spacebar)
  30. }
  31. if (Up == LOW)
  32. {
  33. Keyboard.press(217);
  34. }
  35. if (Up == HIGH)
  36. {
  37. Keyboard.release(217);
  38. }
  39. if (Down == LOW)
  40. {
  41. Keyboard.press(218);
  42. }
  43. if (Down == HIGH)
  44. {
  45. Keyboard.release(218);
  46. }
  47. if (Left == LOW)
  48. {
  49. Keyboard.press(215);
  50. }
  51. if (Left == HIGH)
  52. {
  53. Keyboard.release(215);
  54. }
  55. if (Right == LOW)
  56. {
  57. Keyboard.press(216);
  58. }
  59. if (Right == HIGH)
  60. {
  61. Keyboard.release(216);
  62. }
  63. if (Reset == LOW)
  64. {
  65. Keyboard.press(176); // If reset key (which is pin 8) goes low to press key 224 (return)
  66. }
  67. if (Reset == HIGH)
  68. {
  69. Keyboard.release(176);
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement