How to get arduino to interact with cpp code?

Is there any way to make an arduino interact with cpp code? For context we are using a swerve drive base this year for the first time and we want to have a second driver with a set of buttons for some scoring. I have spent the last day trying to get the arduino to send signals to the c++ code in order to send commands to the robot. I am currently trying to use the Arduino joystick library to get the arduino to act as a controller but its not a library made for frc. 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 device will need to show up in the DS as a joystick in order for robot code to see it. In the DS joysticks view, does the device appear, and do any of the button indicators / axes indicators show anything when you change the inputs to the arduino? What does your arduino code look like?

1 Like

Like said above, you just need the Arduino to emulate a Joystick HID Device. Which you can absolutely do with that library listed as long as you are using a compatible Arduino based on the ATmega32u4 chip, ie. Leonardo, Micro, Pro Micro as instructed in the library’s Readme.

This is the code for the custom Gamepad that 3468 made for Infinite Recharge. Using the same Library you listed on an Arduino Pro Micro:

And while its Java, the process should be basically the same in C++, this is the code utilizing the custom gamepad, the same as any other generic Joystick:

and this is what the custom gamepad looked like


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