/* Complete USB Joystick Example Teensy becomes a USB joystick with 16 or 32 buttons and 6 axis input You must select Joystick from the "Tools > USB Type" menu Pushbuttons should be connected between the digital pins and ground. Potentiometers should be connected to analog inputs 0 to 5. This example code is in the public domain. */ // Configure the number of buttons. Be careful not // to use a pin for both a digital button and analog // axis. The pullup resistor will interfere with // the analog voltage. const int numButtons = 14; // 16 for Teensy, 32 for Teensy++ void setup() { // you can print to the serial monitor while the joystick is active! Serial.begin(9600); // configure the joystick to manual send mode. This gives precise // control over when the computer receives updates, but it does // require you to manually call Joystick.send_now(). Joystick.useManualSend(true); for (int i=0; i= 360) angle = 0; Joystick.hat(1, angle); Joystick.hat(2, angle); Joystick.hat(3, angle); Joystick.hat(4, angle); // Because setup configured the Joystick manual send, // the computer does not see any of the changes yet. // This send_now() transmits everything all at once. Joystick.send_now(); // check to see if any button changed since last time boolean anyChange = false; for (int i=0; i