ArduinoJoystickLibrary icon indicating copy to clipboard operation
ArduinoJoystickLibrary copied to clipboard

single toggle switch causes multiple inputs

Open mm-git01 opened this issue 3 years ago • 3 comments

Description of Issue

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

Technical Details

  • Arduino Board : Pro Micro
  • Host OS : Win 10 same replicated on win 7
  • Arduino IDE Version :1.18.15

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 ?

mm-git01 avatar Jul 24 '21 16:07 mm-git01

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.

CDRXavier avatar Aug 19 '21 17:08 CDRXavier

Are you still seeing this issue?

MHeironimus avatar Mar 30 '22 17:03 MHeironimus

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

CDRXavier avatar Apr 01 '22 18:04 CDRXavier