// 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
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)