Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. #include <Joystick.h>
  2. #include "Keyboard.h"
  3. char lookfront = 3;
  4. char switchA2 = 0;
  5. char switchA3 = 0;
  6. char switch1 = 0;
  7. char switch19 = 0;
  8. void setup() {
  9. pinMode(2, INPUT_PULLUP);
  10. pinMode(3, INPUT_PULLUP);
  11. pinMode(4, INPUT_PULLUP);
  12. pinMode(5, INPUT_PULLUP);
  13. pinMode(6, INPUT_PULLUP);
  14. pinMode(7, INPUT_PULLUP);
  15. pinMode(8, INPUT_PULLUP);
  16. pinMode(9, INPUT_PULLUP);
  17. pinMode(10, INPUT_PULLUP);
  18. pinMode(14, INPUT_PULLUP);
  19. pinMode(15, INPUT_PULLUP);
  20. pinMode(16, INPUT_PULLUP);
  21. pinMode(A0, INPUT_PULLUP);
  22. pinMode(A1, INPUT_PULLUP);
  23. pinMode(A2, INPUT_PULLUP);
  24. pinMode(A3, INPUT_PULLUP);
  25. Joystick.begin();
  26. Keyboard.begin();
  27. }
  28.  
  29. void loop() {
  30. if (digitalRead(2) == LOW && (switch1 == 0))
  31. {
  32. Joystick.setButton(0, 1);
  33. delay(90);
  34. Joystick.setButton(0, 0);
  35. switch1 = 1;
  36. }
  37. if (digitalRead(2) == HIGH && (switch1 == 1))
  38. {
  39. Joystick.setButton(0, 1);
  40. delay(90);
  41. Joystick.setButton(0, 0);
  42. switch1 = 0;
  43. }
  44. if (digitalRead(3) == LOW)
  45. {
  46. Keyboard.press(176); //enter
  47. delay(100);
  48. }
  49. else
  50. {
  51. Keyboard.release(176);
  52. }
  53. if (digitalRead(4) == LOW)
  54. {
  55. Joystick.setButton(4, 1);
  56. }
  57. else
  58. {
  59. Joystick.setButton(4, 0);
  60. }
  61. if (digitalRead(5) == LOW)
  62. {
  63. Joystick.setButton(5, 1);
  64. }
  65. else
  66. {
  67. Joystick.setButton(5, 0);
  68. }
  69. if (digitalRead(6) == LOW)
  70. {
  71. Keyboard.press(177); //esc
  72. delay(100);
  73. }
  74. else
  75. {
  76. Keyboard.release(177);
  77. }
  78. if (digitalRead(7) == LOW)
  79. {
  80. Joystick.setButton(7, 1);
  81. }
  82. else
  83. {
  84. Joystick.setButton(7, 0);
  85. }
  86. if (digitalRead(8) == LOW)
  87. {
  88. Joystick.setButton(8, 1);
  89. }
  90. else
  91. {
  92. Joystick.setButton(8, 0);
  93. }
  94. if (digitalRead(9) == LOW)
  95. {
  96. Keyboard.press(179); //tab
  97. delay(100);
  98. }
  99. else
  100. {
  101. Keyboard.release(179);
  102. }
  103. if (digitalRead(10) == LOW)
  104. {
  105. Joystick.setButton(10, 1);
  106. }
  107. else
  108. {
  109. Joystick.setButton(10, 0);
  110. }
  111. if (digitalRead(14) == LOW)
  112. {
  113. Joystick.setButton(14, 1);
  114. }
  115. else
  116. {
  117. Joystick.setButton(14, 0);
  118. }
  119. if (digitalRead(15) == LOW)
  120. {
  121. Joystick.setButton(15, 1);
  122. }
  123. else
  124. {
  125. Joystick.setButton(15, 0);
  126. }
  127. if (digitalRead(16) == LOW)
  128. {
  129. Joystick.setButton(16, 1);
  130. }
  131. else
  132. {
  133. Joystick.setButton(16, 0);
  134. }
  135. if (digitalRead(A0) == LOW)
  136. {
  137. Joystick.setButton(17, 1);
  138. }
  139. else
  140. {
  141. Joystick.setButton(17, 0);
  142. }
  143. if (digitalRead(A1) == LOW && (switch19 == 0))
  144. {
  145. Joystick.setButton(18, 1);
  146. delay(90);
  147. Joystick.setButton(18, 0);
  148. switch19 = 1;
  149. }
  150. if (digitalRead(A1) == HIGH && (switch19 == 1))
  151. {
  152. Joystick.setButton(18, 1);
  153. delay(90);
  154. Joystick.setButton(18, 0);
  155. switch19 = 0;
  156. }
  157.  
  158. if (digitalRead(A2) == LOW && (switchA2 == 0)) //RIGHT LOOK
  159. {
  160. Joystick.setButton(19, 1);
  161. delay(90);
  162. Joystick.setButton(19, 0);
  163. switchA2 = 1;
  164. }
  165. if (digitalRead(A2) == HIGH && (switchA2 == 1)) //RIGHT LOOK
  166. {
  167. Joystick.setButton(20, 1);
  168. delay(90);
  169. Joystick.setButton(20, 0);
  170. switchA2 = 0;
  171. }
  172.  
  173.  
  174. if (digitalRead(A3) == LOW && (switchA3 == 0)) //RIGHT LOOK
  175. {
  176. Joystick.setButton(21, 1);
  177. delay(90);
  178. Joystick.setButton(21, 0);
  179. switchA3 = 1;
  180. }
  181. if (digitalRead(A3) == HIGH && (switchA3 == 1)) //RIGHT LOOK
  182. {
  183. Joystick.setButton(20, 1);
  184. delay(90);
  185. Joystick.setButton(20, 0);
  186. switchA3 = 0;
  187. }
  188. delay(1);
  189.  
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement