Hello !
I want to connect two Limit Switch for an Joystick and Arduino Pro micro board.
I used this Joystick library : GitHub - 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.
The wiring :
The arduino Sketch :
#include <Joystick.h>
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_GAMEPAD,
2, 0, // Button Count, Hat Switch Count
false, false, false, // 3 mores analogs inputs (for potentiometers for exemple). Set them to "true" if you need them.
false, false, false, // Rx (potentiometer), Ry (Brake loadcell), Rz (potentiometers)
false, false, // Rudder, throttle
false, false, false); // Accelerator, brake, stering
void setup() {
Joystick.begin();
Serial.begin(38400);
// Buttons
pinMode(2, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
}
void loop() {
Joystick.setButton(0, !digitalRead(2));
Joystick.setButton(1, !digitalRead(4));
delay(50);
} // End loop
But it's not working ! When I push the limit switch I have nothing in my Joystick.
Can you help me ? Thanks.
