Open nicolascuadra opened 3 years ago
Have you tried sending the state every loop, not every invocation of a method?
void setup() {
...
Joystick.begin(false);
}
voice loop() {
...
Joystick.sendState();
delay(10);
}
You could also use Joystick.setButton(2, digitalRead(3));
instead of if/else. I'd debounce the buttons first. There are good libs for that.
i made mi arduino pro micro work, windows recognize it as joystick and buttons works fine, but when 2 bottons pressed windows shows all buttons not pressed. is this a problem with mi code ? or the arduino pins?, if pin 3 is set to ground or button 2 is pressed when button 1 is pressed , win shows all buttons released...
include
Joystick_ Joystick;
void setup() { // Initialize Button Pins pinMode(2, INPUT_PULLUP); pinMode(3, INPUT_PULLUP); pinMode(4, INPUT_PULLUP); pinMode(5, INPUT_PULLUP); pinMode(6, INPUT_PULLUP);
// Initialize Joystick Library Joystick.begin(); }
void loop() {
if (digitalRead(2)== LOW){ Joystick.pressButton(1); }else{ Joystick.releaseButton(1); }
if (digitalRead(3)== LOW){ Joystick.pressButton(2); }else{ Joystick.releaseButton(2); } delay(10) }