Interfacing Arduino UNO with Logitech 3D Pro: Code Troubleshooting

Hello! I am very new to Arduino programming and I need to interface a Logitech 3D Pro Extreme Controller with an Arduino UNO board for a project. I was able to connect them both via a USB host shield and I found this preliminary sketch on Github that will interface the controller data with the Arduino.

Here is that sketch:

After making the proper connections to the board and uploading this code, I am presented with this error message:

What should I do in order to resolve these errors?

Welcome

No idea. You can start by posting your code and error messages according to the guidelines here: How to get the best out of this forum

Pay attention to the sections that mention the use of code tags.





/* 
 *  Simplified Logitech Extreme 3D Pro Joystick Report Parser, ready to go.
*/

#include <usbhid.h>
#include <hiduniversal.h>
#include <usbhub.h>
#include "le3dp_rptparser2.0.h"
#include <SPI.h>

USB Usb;
USBHub Hub(&Usb);
HIDUniversal Hid(&Usb);
JoystickEvents JoyEvents;
JoystickReportParser Joy(&JoyEvents);


void setup() {
  Serial.begin(115200);

#if !defined(__MIPSEL__)
  while (!Serial)
    ;  // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif

  Serial.println("Start");
  if (Usb.Init() == -1)
    Serial.println("OSC did not start.");
  delay(200);

  if (!Hid.SetReportParser(0, &Joy))
    ErrorMessage<uint8_t>(PSTR("SetReportParser"), 1);
}


void loop() {
  //
  int Xval;    // 0 - 1023
  int Yval;    // 0 - 1023
  int Hat;     // 0 - 15;
  int Twist;   // 0 - 255
  int Slider;  // 0 - 255
  int Button;  // 0 - 12 (0 = No button)

  Usb.Task();                                                   //Use to read joystick input to controller
  JoyEvents.PrintValues();                                      //Returns joystick values to user
  JoyEvents.GetValues(Xval, Yval, Hat, Twist, Slider, Button);  //Copies joystick values to user







C:\Users\bgibs\AppData\Local\Temp\ccZP60DD.ltrans0.ltrans.o:(.data+0x0): undefined reference to `vtable for JoystickEvents'
C:\Users\bgibs\AppData\Local\Temp\ccZP60DD.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_ControllerParsing.ino.cpp.o.11860':
<artificial>:(.text.startup+0x2c4): undefined reference to `JoystickReportParser::JoystickReportParser(JoystickEvents*)'
C:\Users\bgibs\AppData\Local\Temp\ccZP60DD.ltrans0.ltrans.o: In function `loop':
C:\Users\bgibs\OneDrive\Documents\Arduino\Drone Project Code\ControllerParsing/ControllerParsing.ino:48: undefined reference to `JoystickEvents::PrintValues()'
C:\Users\bgibs\OneDrive\Documents\Arduino\Drone Project Code\ControllerParsing/ControllerParsing.ino:49: undefined reference to `JoystickEvents::GetValues(int&, int&, int&, int&, int&, int&)'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

Ok, here is the code and error messages with code tags.

Thanks for that. I unfortunately can not reproduce your error after fixing the missing } at the end of the code.

I also installed GitHub - felis/USB_Host_Shield_2.0: Revision 2.0 of USB Host Library for Arduino. (via library manager; version1.6.2).

I've copied the two le3dp_rptparser2.0 files from GitHub - BenBrewerBowman/Arduino_Logitech_3D_Joystick: Arduino code for interfacing with the "Logitech Extreme 3D Pro Joystick". A more intuitive version of the "le3dp_rptparser". and added them to a project with your code. You should see 3 files in the IDE as shown below

Notes for next time that you ask for help

  1. Don't mix code and errors :wink: Each with their own code tags please.
  2. Don't make people hunt for libraries or code that you found on the web.

After adding the .cpp file to the sketch, I was able to upload the sketch. I have come across another problem though: when I go to the serial monitor and try to move around the joystick, the printed values are registering, but they stay at 0. Is this something that could be fixed with the code, or would it be more of a hardware issue? (I have the UNO connected to the computer and the controller connected to the host shield, with the host shield connected on top of the UNO)

Thank you for your help thus far! Also, I am sorry you had to hunt for that library. I would have given it to you if I knew it would help solve the problem. I assumed that the base code needed to be altered in some way to make it work.

I can't help with the new problem as I don't have the set up.

And don't worry too much about the libraries; it was for future. You just would have had my reply 10 minutes earlier if you would have provided the information :rofl:

Your error indirectly indicated that you were probably missing a file.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.