Turning an Arduino Uno or Nano into a USB Joystick controller for Atari/Commodore Joysticks | Dansbo Tech Blog

Tech Ramblings

Turning an Arduino Uno or Nano into a USB Joystick controller for Atari/Commodore Joysticks

I have never been able to get used to playing Commodore 64 games in Vice with the keyboard or a gamepad. I don’t have any USB joysticks and I find the ready-made USB to Atari joystick controllers too expensive.

Then I thought that maybe I could use one of my Arduino Nano’s as a Joystick controller, I did find a couple of article that talk about using the Arduino as joystick controller, but it needs to be specific models that are able to act as a USB keyboard in order to function. I don’t have any of those models.

I had almost given up when I stumbled upon a post in the Arduino Forums named Turning an Arduino nano into a joystick. This was exactly what I was looking for and it works.

I have basically copied the content from that post, some I have changed to fit my own needs and some I believe I have improved upon.

We need to know pinout of the DB9 connector. Fortunately Wikipedia has us covered with an article describing just that. This picture is taken from there:

When a button is pressed or joystick i pushed in a direction, the corresponding pin is pulled to ground. This means that all we need to do is connect ground and the different direction- and trigger- pins to the arduino.

I was unable to find a symbol for the DB9 plug as well as the Arduino Nano so you will just have to use your imagination or below table.

DB9 pinArduino pinDescription
8GNDGround connection
62Fire/Trigger button
43Right
34Left
25Down
16Up

Once things are wired up, it is time to do a bit of programming of the arduino.

Above code uses only 5 digital inputs and serial communication so it should be able to run on a variety of Arduino’s. I have only been able to test it on the Uno and Nano.

On the PC end, I am running Linux so a bash script will convert the serial data from the Arduino to keypresses. This is done by the use of the xdotool.

When you are ready to play, you start ardujoy.sh in a shell, fire up Vice and ensure that your joystick uses a keyset. Then all you have to do is configure the keyset the same way as described in the Bash script and you are good to go.

I am unsure if there are any tools for Windows that are able to read input from a serial port and simulate keypresses.

UPDATE: I have created a quick’n’dirty program for Windows that will read a serial port and emulate keypresses just like above bash script. The program is developed using SharpDevelop, it must have a serial port name as the only option. eg:

ardujoy.exe COM1

If you do not want to install Sharpdevelop, create a console application and paste above code, you can download the program here.


Post a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.