MHeironimus / ArduinoJoystickLibrary

An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support.
GNU Lesser General Public License v3.0
2.06k stars 403 forks source link

single toggle switch causes multiple inputs #213

Open mm-git01 opened 2 years ago

mm-git01 commented 2 years ago

Description of Issue

Single toggle on-off switch causes multiple inputs causing x axis to float.

Technical Details

Sketch File that Reproduces Issue

The inbuilt example of joystickbutton

Wiring Details

Pin 10 to positive of toggle switch,pin gnd to negative of toggle switch. I tried changing pins aswell but it was futile.

Additional context

I tried it on three different computers but the issue persists. arduino wiring is fine because the same wiring works as expected with simhub and mobiflight.

Capture

EDIT : Joystick_ Joystick( JOYSTICK_DEFAULT_REPORT_ID, //JOYSTICK_TYPE_MULTI_AXIS, JOYSTICK_TYPE_JOYSTICK, 32, 0, false, // Xaxis false, // Yaxis false, // Zaxis false, // rXaxis false, // rYaxis false, // rZaxis false, // Rudder false, // Throttle false, // Accellerator false, // Brake false // Steering );

This seems to have fixed it,making everything false.Although is the original output i got the intended one ?

CDRXavier commented 2 years ago

You might need to do pinMode(10, INPUT_PULLUP). Adding a button between the pin and ground (and not pressing it) is equal to not connecting anything to the pin, which means that the pin is in a unknown state (high? low?) By specifying input_pullup, you are telling the chip to enable the internal pull-up resistor (a large value, such as 20K, since there is almost no current) so the pin is "pulled" high, and your button will ground it.


Also, the button may be of very poor quality (e.g. bounce), which make what you get actually right.

MHeironimus commented 2 years ago

Are you still seeing this issue?

CDRXavier commented 2 years ago

I have not have seen this issue and have partially reverse-engineered the code to suit my project.