Fala galera!
Estou montando um câmbio sequencial para simulador de corrida e estou com dificildades para fazer funcionar adequadamente.
Usei um projeto existente na internet (DIY Racing Sim Sequential Shifter by bbeavis - Thingiverse) e tentei aproveitar inclusive o código. Mas ele não funcionou adequadamente, acredito que por ser antigo houve alguma atualização nas biblioteca <Joystick.h>. Tentei fazer uns ajustes, mas não deu certo.
Segue o código que estou usando para que me ajudem a entender o que está errado:
#include <Joystick.h>
//Create the joystick
Joystick_ Joystick(0x15, JOYSTICK_TYPE_JOYSTICK, 5, 0, false, false, false, false, false, false, false, false, false, false, false);
//const bool initAutoSendState = true;
// Define Input Pins
int upPin = 5;
int downPin = 6;
// Set button default states
int Up = 0;
int Down = 0;
void setup() {
// Initialize Button Pins
pinMode(upPin, INPUT_PULLUP);
pinMode(downPin, INPUT_PULLUP);
// Initialize Joystick Library
Joystick.begin();
}
void loop() {
Up = digitalRead(upPin);
Down = digitalRead(downPin);
Joystick.setButton(0,!Up);
Joystick.setButton(1,!Down);
delay(50);
}
O câmbio tem dois "botões", um para subir as marchas e outro para descer. Com este código ele até reconheceu os botões, mas no jogo ele não funciona adequadamente. Ele sobre apenas uma e desce apenas uma marcha.
Sugestões para fazer funcionar adequadamente?