With two boards, only the first will be recognized
Description of Issue
If connect two boards with different sketches, but bot uses the arduino joystick library, only the first one which is attached to the pc will work as gamecontroller. The second one will produce a windows error if you go into the settings. Something like: The Gamecontroller isn't attached correctly. PLease check if its attached proper.
Technical Details
- Arduino Board (e.g. Arduino Leonardo): https://paradisetronic.com/de/arduino/pro-micro-modul-atmega32u4-5v-16mhz-arduino-kompatibel
- Host OS (e.g. Windows 10): Windows 10
- Arduino IDE Version (e.g. 1.8.3): 1.8.13
Sketch File that Reproduces Issue
// USB 5 AXIS Controller
// Use with Arduino Leonardo or ProMicro.
// Install Joystick library
// AMSTUDIO 2018
// YT https://www.youtube.com/channel/UCQS1ZB3BVSrBo3tCs7PyfxQ
// Wiring + Setup https://youtu.be/iKIrbF6GnZ0
// Copyright _ Non Commerical_ Not for Resale https://creativecommons.org/licenses/by-nc-nd/4.0/
#include <Joystick.h>
Joystick_ Joystick(0x04,JOYSTICK_TYPE_GAMEPAD,
0, 0, // Button Count, Hat Switch Count
false, false, true, // X and Y, but no Z Axis
false, false, false, // No Rx, Ry, or Rz
false, true, // No rudder or throttle
false, true, false); // No accelerator, brake, or steering
int throttle = 0;
int brake = 0;
int clutch = 0;
const bool initAutoSendState = true;
void setup()
{
Joystick.begin();
}
void loop(){
throttle = analogRead(A0);
throttle = map(throttle,1023,0,255,0);
Joystick.setThrottle(throttle);
brake = analogRead(A1);
brake = map(brake,0,1023,0,255);
Joystick.setBrake(brake);
clutch = analogRead(A2);
clutch = map(clutch,1023,0,255,0);
Joystick.setZAxis(clutch);
delay (50);
}
//AMSTUDIO Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
Read the documentation.
uint8_t hidReportId - Default: 0x03 - Indicates the joystick's HID report ID. This value must be unique if you are creating multiple instances of Joystick. Do not use 0x01 or 0x02 as they are used by the built-in Arduino Keyboard and Mouse libraries.
In the beginning of the sketch this ID must be set if you intend to run multiple devices.