How to make a PC Arcade controller using the Arduino Leonardo
As well as being able to run programs like other Arduino’s, the Leonardo and Micro models can emulate a USB Keyboard or mouse when plugged into a USB port.
In this tutorial we will see how to connect Arcade controllers to a Leonardo, and use them in the popular retro arcade emulator MAME to play all those nostalgic video games.
You could also use the Arduino MICRO which is the same as the Leonardo but much smaller.
We will connect an 8 way joystick and an arcade button to play one of my favorite game: GALAGA!
As you can see in the schematic above, most arcade joystick are nothing more than regular switches that get activated when you move the stick in a specific direction.
The NO (Normally Open) pin of the switches are connected to pin 2, 3 and 4 of the Leonardo.
The COM or ground pins are connected together and then go to the GND pin of the Leonardo.
Before we start we need to know what Keyboard shortcuts the MAME emulator uses.
Depending on the game you play you might need more or less keys, since some of them use more buttons and might be 2 Players.
For our tutorial we only need to know the keys for the Player 1 joystick and fire button.
MAME default keys for the P1 joystick are the Arrow keys and the Left-Ctrl key for fire.
Here are the default keyboard shortcuts in MAME.
This list is simplified since there’s a lot more available.
You can do a Google search to find out more.
|Keyboard Key||MAME Command|
|1,2||Players 1 -2 Start buttons|
|Arrow Keys||Player 1 Control|
|Left Ctrl||Fire 1|
|Left Alt||Fire 2|
|R,F,G,D||Player 2 Control|
|A||P2 Fire 1|
|S||P2 Fire 2|
|Q||P2 Fire 3|
As always please watch our Tutorial video for more information.
Copy the above Sketch code in your Arduino IDE software to program your Arduino Leonardo or Micro.
The MAME version we used in this tutorial is called MAMEUI32.
You can Download MAMEUI32 from here: MAMEUI32 Download.