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.12k stars 411 forks source link

Button stuck active in the HID #127

Open lefouduquebec opened 4 years ago

lefouduquebec commented 4 years ago

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

//--------------------------------------------------------------------

include

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 
![image](https://user-images.githubusercontent.com/11757122/68225382-56677280-ffbe-11e9-99a2-16cbb388ffe0.png)

![1](https://user-images.githubusercontent.com/11757122/68225531-90d10f80-ffbe-11e9-98a9-38d98ce92a83.jpg)
![2](https://user-images.githubusercontent.com/11757122/68225532-90d10f80-ffbe-11e9-97a0-9fca6383c1cc.jpg)

Sorry for my english i speak french 
MrDannyPicard commented 4 years ago

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/