ArduinoJoystickLibrary
ArduinoJoystickLibrary copied to clipboard
Button stuck active in the HID
Description of Issue
Enter description of issue here. Include a clear and concise description of what you expected to happen and what actually happened.
Technical Details
- Arduino Board Leonardo):
- Host OS Windows 10
- Arduino IDE Version e.g. 1.8.3
//--------------------------------------------------------------------
#include <Joystick.h>
Joystick_ Joystick;
void setup() { // Initialize Button Pins pinMode(9, INPUT_PULLUP); pinMode(10, INPUT_PULLUP); pinMode(11, INPUT_PULLUP); pinMode(12, INPUT_PULLUP);
// Initialize Joystick Library Joystick.begin(); }
// Constant that maps the phyical pin to the joystick button. const int pinToButtonMap = 9;
// Last state of the button int lastButtonState[4] = {0,0,0,0};
void loop() {
// Read pin values for (int index = 0; index < 4; index++) { int currentButtonState = !digitalRead(index + pinToButtonMap); if (currentButtonState != lastButtonState[index]) { Joystick.setButton(index, currentButtonState); lastButtonState[index] = currentButtonState; } }
delay(50); }
Sketch file goes here (if applicable)
## Wiring Details
Any pin wiring details that may be relevant.
## Additional context
I connect my button to the protoboard like you can see in the picture.
My issue is that when i press on my button the Axis on th HID go on the left up corne and the button stay press on the hid . when i press the button again the Axis stay on the top left corner but the button on the HID go off for the time i press on it. When i release button came back on on the hid like if i was pressing on it.
I am a newbie with Arduino if someone can help me, I will really appreciate
Maybe is the way i connect my button can you help me



Sorry for my english i speak french
regarde ce post sur reddit. Ces un code que j'ai fait très simple avec joystick.h https://www.reddit.com/r/flightsim/comments/ir5t38/almost_finished_making_my_172_g1000_button_box/g4y7ecq/