Saturday, July 09, 2022

Simple Arduino Leonardo USB Game Pad

Parts

Required Parts

Optional Parts

Hardware Assembly

  1. If using a case, place the Arduino Leonardo inside the case per the instructions provided with the case.
  2. Insert the Funduino Joystick Shield onto the Arduino Leonardo.

Software

  1. Download the latest v2 version of the Arduino Joystick Library from https://github.com/MHeironimus/ArduinoJoystickLibrary: https://github.com/MHeironimus/ArduinoJoystickLibrary/archive/refs/heads/version-2.0.zip.
  2. To install the library in the Arduino IDE, select Sketch > Include Library > Add .ZIP Library.... Browse to where the downloaded ZIP file is located and click Open. The Joystick library's examples will now appear under File > Examples > Joystick.
  3. Open the Funduino Joystick Shield example by selecting File > Examples > Joystick > FunduinoJoystickShield. Verify the correct Port is selected in the Arduino IDE and select Upload.
  4. On Microsoft Windows, the joystick can be tested using the “Game Controllers” dialog.

6 comments:

Candido M said...

Mr Matthew Heironimus.

Sorry for my bad english.
I am with arduino making his joystick project, which many of us use. My question is: Is it possible for the same post as sending text through the serial port, without losing the gamedpack format for the winwdows joy cpl? It is to put an ldc screen to the joystick thanks

Matthew Heironimus said...

If your question is can I still use the serial port with this library, the answer is yes.

Veysel arslan said...

Hi Matthew i write joystick 1(32 button+analog stick+dpad) from Matthew , joy.cpl is working but buttons not working, How can i solve this problem ?

Matthew Heironimus said...

I suggest you open an issue on the GitHub repository (https://github.com/MHeironimus/ArduinoJoystickLibrary/issues), but you will need to include a lot more details than you have here.

Zeno Silva said...

Hello Matthew, I have been using one of your examples for a button box using an Arduino Leonardo. The idea is simple but I have very limited knowledge but I think for you this should be fairly simple.

I changed your code and for the good or bad it works, I have 8 momentary switches that toggle each one an individual LED and work as a joystick button. This works well, but the last thing I want to add and can't figure out is 3 rotary encoders (don't need the button function just rotary). I have been using one of your examples and made some sort of frankestein, but since my knowldge is next to zero, nothing I do allows the encoders to work.

I uploaded to Github the .ino that I am using, I commented the encoders. Can you shed some light? Basically all I need is to add 3 rotary encoders and keep all buttons and LED toggle (if you see something that can be improved by all means you can change) :)

https://github.com/zenomsn/Joystick-with-LEDs

Matthew Heironimus said...

Zeno Silva - The library does not deal with the reading of input hardware devices, such as rotary encoders. I have not personally used them and am not familiar with using them in a project. I suggest you investigate projects on how to read rotary encoders and take those values and feed them into the appropriate Joystick library functions. Here are a few examples I found:

https://www.instructables.com/Tutorial-of-Rotary-Encoder-With-Arduino/
https://www.circuitbasics.com/how-to-setup-and-program-rotary-encoders-on-the-arduino/
https://dronebotworkshop.com/rotary-encoders-arduino/