/* Basic USB Joystick Example Teensy becomes a USB joystick You must select Joystick from the "Tools > USB Type" menu Pushbuttons should be connected to digital pins 0 and 1. Wire each button between the digital pin and ground. Potentiometers should be connected to analog inputs 0 to 1. This example code is in the public domain. */ // Pin 13 has an LED connected on most Arduino boards. // Pin 11 has the LED on Teensy 2.0 // Pin 6 has the LED on Teensy++ 2.0 // Pin 13 has the LED on Teensy 3.0 // give it a name: #define LED 11 // https://www.pjrc.com/teensy/pinout.html #define D0 5 #define D1 6 void setup() { pinMode(D0, INPUT_PULLUP); pinMode(D1, INPUT_PULLUP); // initialize the digital pin as an output. pinMode(LED, OUTPUT); Joystick.useManualSend(true); } void loop() { // read analog inputs and set X-Y position //Joystick.X(analogRead(0)); //Joystick.Y(analogRead(1)); // read the digital inputs and set the buttons int d0 = digitalRead(D0);// trigger int d1 = 1 - digitalRead(D1);// light // set "buttons" state Joystick.button(1, d0); Joystick.button(2, d1); digitalWrite(LED, d0 ? HIGH : LOW); // turn the LED on (HIGH is the voltage level) Joystick.send_now(); }