Hi, firstly I am really sorry if this is the wrong spot to post, if it is please direct me to where I should move this thank you.
I am attempting to hook up my logitech g29 shifter to an arduini pro micro (but in IDE it's an arduino leonardo) and I'm following this tutorial,(DIY LOGITECH USB SHIFTER ADAPTER DRIVING FORCE - YouTube) [DIY LOGITECH USB SHIFTER ADAPTER DRIVING FORCE by amstudio]
I have checked for continuity so I know my solders are good so this is definitely a coding error on my part. I have installed the correct library (joystick) and I am getting stuck with error compiling for board arduino leonardo. I used to code it as a pro micro but that bricks the bootloader and I end up resetting and if it's coding it as a leonardo I have no issues with other programs. Again, I am very new to this forum so I apologize in advanced if this is not formatted or posted correctly.
Thank you for your patience to whoever reads this!
//Logitech Driving Force Shifter USB Adapter
//By Armandoiglesias 2018
//Based on Jason Duncan functionreturnfunction Project
//Video tutorial https://www.youtube.com/watch?v=dLpWEu8kCec
//Use Arduino Leonardo
//Install Joystick Library
//Attribution-NonCommercial-NoDerivatives 4.0 International
#include <Joystick.h>
// Create the Joystick
Joystick_ Joystick;
// H-shifter mode analog axis thresholds
#define HS_XAXIS_12 400
#define HS_XAXIS_56 500
#define HS_YAXIS_135 800
#define HS_YAXIS_246 300
// Sequential shifter mode analog axis thresholds
#define SS_UPSHIFT_BEGIN 670
#define SS_UPSHIFT_END 600
#define SS_DOWNSHIFT_BEGIN 430
#define SS_DOWNSHIFT_END 500
// Handbrake mode analog axis limits
#define HB_MAXIMUM 530
#define HB_MINIMUM 400
#define HB_RANGE (HB_MAXIMUM-HB_MINIMUM)
// Digital inputs definitions
#define DI_REVERSE 1
#define DI_MODE 3
#define DI_RED_CENTERRIGHT 4
#define DI_RED_CENTERLEFT 5
#define DI_RED_RIGHT 6
#define DI_RED_LEFT 7
#define DI_BLACK_TOP 8
#define DI_BLACK_RIGHT 9
#define DI_BLACK_LEFT 10
#define DI_BLACK_BOTTOM 11
#define DI_DPAD_RIGHT 12
#define DI_DPAD_LEFT 13
#define DI_DPAD_BOTTOM 14
#define DI_DPAD_TOP 15
// Shifter state
#define DOWN_SHIFT -1
#define NO_SHIFT 0
#define UP_SHIFT 1
// Shifter mode
#define SHIFTER_MODE 0
#define HANDBRAKE_MODE 1
// LED blink counter
int led = 0;
// Shifter state
int shift = NO_SHIFT;
// Handbrake mode
int mode = SHIFTER_MODE;
int b[16];
int gear = 0; // Default value is neutral
// Constant that maps the phyical pin to the joystick button.
//const int pinToButtonMap = 9;
void setup() {
// G29 shifter analog inputs configuration
pinMode(A0, INPUT_PULLUP); // X axis
pinMode(A2, INPUT_PULLUP); // Y axis
pinMode(2, INPUT);
for (int i = 0; i < 16; i++) b[i] = 0;
b[DI_MODE] = 0;
// Initialize Joystick Library
Joystick.begin();
}
// Last state of the button
int lastButtonState = 0;
void loop() {
int x = analogRead(0); // X axis
int y = analogRead(2); // Y axis
int _isreverse = digitalRead(2);
int _gear_ = 0;
if ( _isreverse == 1 ) {
_gear_ = 8;
b[DI_REVERSE] = 1;
} else {
if (b[DI_MODE] == 0) // H-shifter mode?
{
if (x < HS_XAXIS_12) // Shifter on the left?
{
if (y > HS_YAXIS_135) _gear_ = 1; // 1st gear
if (y < HS_YAXIS_246) _gear_ = 2; // 2nd gear
}
else if (x > HS_XAXIS_56) // Shifter on the right?
{
if (y > HS_YAXIS_135) _gear_ = 5; // 5th gear
if (y < HS_YAXIS_246) _gear_ = 6; // 6th gear
}
else // Shifter is in the middle
{
if (y > HS_YAXIS_135) _gear_ = 3; // 3rd gear
if (y < HS_YAXIS_246) _gear_ = 4; // 4th gear
}
}
}
if (gear != 6) b[DI_REVERSE] = 0; // Reverse gear is allowed only on 6th gear position
if (_gear_ != gear ) {
gear = _gear_;
desactivar();
Joystick.setButton(gear - 1, HIGH);
}
delay(50);
}
void desactivar() {
// Depress virtual button for current gear
for (int i = 0; i <= 10 ; i++ ) Joystick.setButton(i, LOW);
}
ERROR MESSAGE:
Arduino: 1.8.14 Hourly Build 2021/04/30 05:33 (Windows 10), Board: "Arduino Leonardo"
libraries\Joystick\Joystick.cpp.o (symbol from plugin): In function `Joystick_::Joystick_()':
(.text+0x0): multiple definition of `Joystick'
sketch\Logitech_Shifter_USB.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Leonardo.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.