Progress Bar

Skip to main content

Jaycar
...

Arcade Joystick

Arcade Joystick

Difficulty
Entertainment

Summary

There's a lot of arcade emulators out there that can run on many computers including the Raspberry Pi so it only makes sense to play these emulators on some authentic hardware. Here we'll show you how to build an arcade style joystick using our new Arcade Pushbuttons and Arcade Joystick. We've got a Leonardo main board to emulate a USB keyboard so it can be used with any software that you can play with a keyboard. Just like any other Arduino design, it can of course be customised to more buttons or even mapped to different keys. We've built ours in an ABS enclosure for portability but there's no reason you couldn't mount the controls directly to an arcade cabinet or even a coffee table.

Materials Required

1
1
4
1
2
1

Joystick

Leonardo

Wire Colour

Grounds (COM)

GND

White and Black

Joystick Up

D2

Brown

Joystick Right

D3

Red

Joystick Down

D4

Orange

Joystick Left

D5

Yellow

Green Button

D6

Green

Yellow Button

D7

Blue

Blue Button

D8

Purple

Red Button

D9

Grey


Downloads

Source code

Assembly

We built our joystick into a HB6248 enclosure which required drilling a number of 28 mm holes for the buttons and the joystick shaft as well as some smaller ones for the joystick mounting screws and for the cable to leave the enclosure. To mount the joystick we unscrewed the top plate and then clamped the lid of the box between the body and top plate of the joystick. Because there are so many ways of building this we will focus on the electronics rather than hardware side of construction. It might pay to test the mechanical build before connecting the electronics to make sure the wires are long enough and that you don't have to pull it apart after wiring it up.

built our joystick into a HB6248

The joystick has four microswitches and each pushbutton has a single microswitch. For each microswitch we want to connect the COM to GND, and then the N/O tabs are connected to an IO pin on the Leonardo to sense whether the microswitch has been triggered. For the joystick these are the only two tabs. For the pushbuttons they are the lower two tabs.

The joystick

Programming


Download the source code, extract into a new folder, open the .ino file in the Arduino IDE and press upload.

The sketch does not require any external libraries - the Keyboard.h library is included with recent versions of the IDE. The sketch will not work on boards like the UNO or Mega as they do not have USB support built into the main IC. Choose the Leonardo and its serial port and upload.

The sketch is very simple - the arrays at the start hold the digital pins and their corresponding keyboard keys. The number of pins and keys needs to match the PINCOUNT defined value. After initialising, the Leonardo scans the pins and if it detects a change it sends the corresponding key press or key release. A good guide to the keymappings and friendly names of some of the keys can be found on this page: https://www.arduino.cc/en/Reference/KeyboardModifiers.

Future Improvements


As noted above, the PINCOUNT value can be changed and the Leonardo has 20 IO pins plus another three on the ISP header so that if you need more buttons extra pins can be allocated. We only stopped at four buttons because the enclosure wasn't big enough to fit more.Alternatively, you could add a second joystick and some player two buttons so that the joystick will work for two-player games. USB supports up to 127 devices per bus so there is no reason a second unit cannot be built but with the keys programmed to their player two equivalents thus allowing two players to play at the same time.

Similar projects you may be interested in

Entertainment
Music Beat Bar
Difficulty

Basic Linux Guide
Entertainment
Basic Linux Guide
Difficulty

Entertainment
Memory Gesture Game
Difficulty

Entertainment
Arduino Learning
Difficulty