Guest User

Untitled

a guest
Apr 29th, 2016
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Basic USB Joystick Example
  2. Teensy becomes a USB joystick
  3.  
  4. You must select Joystick from the "Tools > USB Type" menu
  5.  
  6. Pushbuttons should be connected to digital pins 0 and 1.
  7. Wire each button between the digital pin and ground.
  8. Potentiometers should be connected to analog inputs 0 to 1.
  9.  
  10. This example code is in the public domain.
  11. */
  12.  
  13. void setup() {
  14. pinMode(0, INPUT_PULLUP);
  15. pinMode(1, INPUT_PULLUP);
  16. pinMode(2, INPUT_PULLUP);
  17. pinMode(3, INPUT_PULLUP);
  18. pinMode(4, INPUT_PULLUP);
  19. pinMode(5, INPUT_PULLUP);
  20. pinMode(6, INPUT_PULLUP);
  21. pinMode(7, INPUT_PULLUP);
  22. pinMode(8, INPUT_PULLUP);
  23. pinMode(9, INPUT_PULLUP);
  24. pinMode(10, INPUT_PULLUP);
  25. }
  26.  
  27. void loop() {
  28. // read the digital inputs and set the buttons
  29. Joystick.button(1, !digitalRead(0));
  30. Joystick.button(2, !digitalRead(1));
  31. Joystick.button(3, !digitalRead(2));
  32. Joystick.button(4, !digitalRead(3));
  33. Joystick.button(5, !digitalRead(4));
  34. Joystick.button(6, !digitalRead(5));
  35. Joystick.button(7, !digitalRead(6));
  36. Joystick.button(8, !digitalRead(7));
  37. Joystick.button(9, !digitalRead(8));
  38. Joystick.button(10, !digitalRead(9));
  39. Joystick.button(11, !digitalRead(10));
  40.  
  41. delay(20);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment