Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 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.
- */
- void setup() {
- pinMode(0, INPUT_PULLUP);
- pinMode(1, INPUT_PULLUP);
- pinMode(2, INPUT_PULLUP);
- pinMode(3, INPUT_PULLUP);
- pinMode(4, INPUT_PULLUP);
- pinMode(5, INPUT_PULLUP);
- pinMode(6, INPUT_PULLUP);
- pinMode(7, INPUT_PULLUP);
- pinMode(8, INPUT_PULLUP);
- pinMode(9, INPUT_PULLUP);
- pinMode(10, INPUT_PULLUP);
- }
- void loop() {
- // read the digital inputs and set the buttons
- Joystick.button(1, digitalRead(0));
- Joystick.button(2, digitalRead(1));
- Joystick.button(3, digitalRead(2));
- Joystick.button(4, digitalRead(3));
- Joystick.button(5, digitalRead(4));
- Joystick.button(6, digitalRead(5));
- Joystick.button(7, digitalRead(6));
- Joystick.button(8, digitalRead(7));
- Joystick.button(9, digitalRead(8));
- Joystick.button(10, digitalRead(9));
- Joystick.button(11, digitalRead(10));
- delay(20);
- }
Advertisement
Add Comment
Please, Sign In to add comment