Projects

Retro Gaming!

Desktop Arcade Machine Using Raspberry Pi

Dean Corva

Issue 30, January 2020

Bringing back the arcade machine to bond new generations with the old.

BUILD TIME: 8 HOURS
DIFFICULTY RATING: Intermediate

Scrounging change for the local arcade machine is a problem no millennial or post-millennial has to face. As the demand for new, online, insanely realistic games is increasing, old games are slowly coming back in trend. The simplistic nature of an old game warms the hearts of prior generations as they take a ride through nostalgia lane. Any hardcore gamer can appreciate a classic round of arcade. There aren’t many people that don’t appreciate an arcade machine, as the humble arcade machine has shaped at least one story in everyone’s life. Let’s reignite that joy brought to kids of the ’80s by building a desktop arcade machine, igniting that same joy to new generations.

THE BROAD OVERVIEW

It would be quite impractical to place a full size, bulky arcade machine in our homes. I certainly can’t fit one, if you have the room for these beasts then enjoy! There is, however, good news for the rest of us wanting a compact solution without sacrificing that beautiful aesthetic we are all so familiar with. Using easily accessible tools and materials, we can fabricate our own arcade machine, at a convenient size.

Dimensions for this arcade machine measure 500mm wide x 400mm deep x 600mm high, however, this size isn’t limited, if you wish to make a smaller or larger arcade machine, then be my guest! As the electronics used can be manipulated to suit your needs.

In basic terms, the Desktop Arcade Machine runs an Arcade Machine emulator on a small computer running dedicated software. The user is interfaced with a standard arcade layout of 8 buttons and 1 joystick per player. The Desktop Arcade Machine is fabricated from sheets of timber and uses a Raspberry Pi as the small computer running an img file labelled RetroPie as the emulator, which is free to download from https://retropie.org.uk/download/

I personally chose to have two players on my Arcade machine, however, you can add as many as you want, as long as you have enough USB ports on the Raspberry Pi. A USB interface is connected to each bank of 8 buttons and a joystick, to interface the user to the game selected. Depending on user preference, button selection is configured when RetroPie is first started, with every user having different preferences and every game having different layouts, changes to the configured buttons can be made at any time to reconfigure the buttons.

A 16x9 aspect ratio screen was used for the viewing platform, with the video signal fed from the Raspberry Pi’s HDMI output. Audio for the machine is fed from the Raspberry Pi’s 3.5mm audio output, configured in the settings menu. This audio signal runs into an audio amplifier feeding two speakers. RetroPie can emulate different consoles, however, for this tutorial, it’ll be emulating an Arcade Machine.

A separate power button was programmed into the Raspberry Pi where GPIO 3 is constantly set high. When GPIO 3 is set low, the Raspberry Pi goes into safe boot mode or safe shutdown mode. GPIO 3 is set low using a pushbutton, sending the signal to ground. A custom relay circuit controlling auxiliary power for the arcade machine was programmed into the Raspberry Pi, where GPIO 14 is constantly set high when the Raspberry Pi is booted. When the Raspberry Pi goes into safe shutdown mode, GPIO 14 is set low. This is connected to the signal of a 5V relay, turning on the auxiliary power or lights of the arcade machine.

Electronics easily accessible thanks to two hinges, this allows easy serviceability or expansion for adding more arcade buttons.
HARDWARE Required:
2 x Hinges
3 x 1200x600x12mm Timber Sheets
500(L) x 12(Dia.)mm Dowell
1 Litre of Black Paint
Packet of Nails
Packet of Screws
1 Metre of String
PVA Glue
TOOLS Required:
Hammer
Drill
29mm holesaw
Handsaw or Router or Jigsaw
Measuring Tape
Screwdriver
Paint Roller
Paint Brush
PARTS REQUIRED:Jaycar
2 x JoysticksSM1052
8 x Arcade Buttons BlueSP0666
8 x Arcade Buttons GreenSP0665
2 x USB InterfaceXC9046
1 x Momentary SwitchSP0798
1 x Relay ModuleXC4419
1 x Raspberry Pi 3BXC9000
1 x SD CardXC4989
1 x HDMI CableWV7913
1 x HDMI-DVI Adaptor^PA3642
1 x USB Micro LeadXC5072
1 x USB Strip LightZD0571
Packet x Male to Female Jumper WiresWC6028
1 x 3.5mm Audio CableWA7006
1 x IEC Power LeadPS4103
1 Metre x Cable SockWH5636
Packet of Cable TiesHP1200
Packet of Cable Tie MountsHP1195
Packet of Spade LugsPT4513
30 Metres of Figure 8 WireWB1703
Pack of mixed HeatshrinkWH5525
Roll of Electrical TapeNM2856
PowerboardMS4040
OPTIONAL:
1 x Monitor
1 x Amplifier
2 x Speakers

^ Only required if your monitor has DVI instead of HDMI

The Build:

Construction

To ensure all the components worked correctly, a quick prototype was assembled. This was done by quickly connecting all the pushbuttons to ports 1-8 of the USB interface and connecting the joystick to the allocated port of the USB interface. The two USB interfaces were then connected into the Raspberry Pi, loaded with RetroPie on an SD card.

The screen was temporarily used to test all the fundamental connections of the arcade machine and displayed correctly on the screen. This is recommended, as the Desktop Arcade Machine is snuggly fitted to the enclosure to be built. Should the originally used screen fail, or not be available to other builders, some flexibility needs to be designed-in.

Building the Arcade Machine begins with cutting the timber sheets sourced from a local hardware store. Often the hardware store will cut the timber for you if the cut is square and the material is not too dense. This means the only cut needed is the custom shaped side panels. These panels can be of any shape you desire, however, the provided shape is a good guideline for an attractive arcade machine.

To cut the side panels so they are identical, we have a few tricks involving a piece of string, double-sided tape, a nail and a form of cutting tool (jigsaw, router or handsaw). Before marking-out and cutting the side panels, we need to join the two sheets together. To do this, apply double-sided tape to one of the 12mm sheets and adhere the second sheet to it, as square to the first piece as possible. Keep in mind, once the two panels are together, the double-sided tape really doesn’t allow for any twisting. Also, do not apply too much double-sided tape as the pieces will need to be pulled apart. Generally, about 4 x 10cm strips on each corner will be more than sufficient.

Note: Good practice would be to trim both datum sides to ensure same corner angle and complete alignment.

Short piece of double-sided tape in each corner
Two sheets squarely joined together

Now, here’s the secret part. Tie a piece of string to the cutting tool being used and to the timber nail. Hammer the nail into the two sheets of wood on the axis that freely spins to the shape of the arcade machine. Applying tension to the string while cutting creates a perfect rounded cut for the arcade side panels.

Now cut square edges to finish off the piece. Separating the two sheets we have two perfectly mirrored side panels ready for the infill cuts.

With the infilled pieces cut from either the hardware store or yourself, we’re ready to nail and glue the pieces into place to form the main frame. However, before doing that, prepare the screen to be mounted into the enclosure. I used a recycled display that was being thrown in the bin. You can source these displays everywhere, as generally, companies, schools, and universities will throw these displays out when upgrading systems, so scoring one cheap or free is quite achievable.

With the display I’ve used, I’ve ripped the plastic cover off to make for a cleaner solution, however, this is not necessary. On the back of the display, 4 mounting holes can be seen for mounting the display. Before assembling the enclosure, pre-drill these holes for the display mount, as drilling the panel while the enclosure is assembled is more difficult.

Nailing and gluing the enclosure together should be completed now, keeping in mind the width of these cuts is suited to the display I’ve used. Different screens will also fit this width, however, can be custom cut for different widths.

Front and rear view of the assembled timber pieces before painting

Time to cut the control panel. Beginning with the layout of the joystick and buttons, design a layout that suits your personal preference where the location is best suited. I chose a traditional layout similar to original arcade machines, with cascading 6 buttons to the right of a joystick and two horizontal buttons located above.

Once you’ve decided on a layout, be sure to use a pencil to draw lines exactly where the holes need to be drilled, while keeping symmetry. All standard size arcade buttons need a 29mm hole drilled, however, be sure to measure what size hole your arcade buttons need.

Using a 29mm holesaw, drill into the top side of the control panel where all the buttons are being placed. The reason for drilling into the top side is due to holesaw’s having a tendency to blowout when close to the end of cutting. This can chip the timber and ruin the face of the control panel.

The holesaw can also be used to cut the hole for the joystick, this size hole is of less importance, as long as the movement of the joystick clears the walls. Mounting the power button to the control panel was done on this arcade machine, however, the location of this does not need to be on the control panel.

Once all holes have been cut on the control panel, flip the panel over and drill holes for the joystick mounting holes. Test fit all the components to ensure everything is symmetrical.

The arcade machine now looks like an arcade machine, time to give it a paint job. After removing all the components, give 2-3 coats using paint of your choice to seal the timber and improve structural resilience to being damaged. I used black exterior paint as its cheap and provides good scratch resistance.

Using a foam paint roller for the majority of the enclosure provides a clean solution with little streak marks you normally get with a paintbrush. Use a paintbrush for tough areas to reach. Remounting the equipment for the final time and adding a cover over the screen finished the hardware build.

Moving onto wiring, be sure to follow the wiring diagram to ensure no mistakes are made as improper wiring can result in the arcade machine not operating properly.

Beginning the wiring on the control panel started with mounting the USB interfaces to the underside using a hot glue gun.

Using the provided connectors with the interface, plug in the buttons on the ports labelled 1-8 to the button switches. The polarity of the red and black wires do not matter as the switch shorts the two together when pressed. A supplied cable for the joystick is pre-terminated with a 5 pin connector, plug in the side labelled joystick on the USB interface. If you run into the same issue as mine where the 5 pin connector did not match the joystick pinout connect 5 male to female jumper leads and heat-shrink the join. This allows the connection of each pin to match the pinout of the joystick. Once completed, use cable ties to neaten the looms of both controllers.

Wiring in the lighting for the arcade buttons and joysticks isn’t necessary, however, I haven’t witnessed many arcade machines without multiple forms of lighting to attract users from all directions. Using figure 8 wire to each button and joystick, terminate spade connectors on each wire and connect to the lighting, keeping in mind the lighting is polarity sensitive if constructed with LEDs.

I personally use the trace on the figure 8 wire as the positive, however, if you wish to use it as the negative that works perfectly fine, just keep in mind which convention you have used. Make sure the figure 8 used is capable of carrying the current necessary for the lights, your local Jaycar/Altronics will be able to assist you with this. Connecting the USB cable to the USB interface was also done in this step. Once again using cable ties and cable tie mounts to neaten the job is a small step to make servicing later a breeze.

A cable sock provides a neat solution and protects any cable that may be under movement, such as the case for the easy access control panel to be shown later. To make cable socking easy, pull all the cables out to the furthest point, now using electrical tape, tape down the ends of all the cables at their finishing point, effectively creating one long cable loom. This allows the cable sock to slide over the cables easy, not damaging the cables or the sock itself.

Using the same electrical tape, tape down the sock to the cable of the control panel end.

Push excess sock over the tape, creating a clean solution that won’t move over time, and do the same for the opposing end.

Terminate any cables exiting the sock, including power for the lights, and the power button if you chose to mount to the control panel.

Implementing the previously mentioned, easy access for the control panel was done using two small hinges screwed into the enclosure and control panel.

Using a 5 volt 3 amp power supply, wire the positive of the supply into the normally open contact of the relay. From the common point of the relay, wire into the positive of the lighting circuit. Then wire the negative of the lighting circuit into the negative of the power supply. Power the logic side of the relay to the 5V and ground of the Raspberry Pi. Now connect the logic pin to GPIO 14. This allows the lighting circuit to turn on and off with the system.

Connect a momentary switch to GPIO 3 and ground, for the power button. Connect the two USB interfaces to two of the Raspberry Pi’s USB ports. Connect an HDMI cable to the HDMI output of the Raspberry Pi (this feeds to an HDMI to DVI adaptor for my setup, as the screen does not have an HDMI input). Connect a 3.5mm lead to the audio output of the Raspberry Pi. This feeds to an amplifier, powering speakers. Finally, connect a 5 volt 3 amp Raspberry Pi power supply to the Raspberry Pi, powering the system. A 1 metre USB RGB strip light was plugged into an additional port of the Raspberry Pi for extra lighting, also turning on/off with the system. That’s the hardware for the system complete!

SETUP

Setting up the Raspberry Pi begins with installing the .img file (downloaded from https://retropie.org.uk/download/) on a microSD card. Dependant on how many games you plan to install will determine the size of microSD card used. Plug the SD card into your computer using a microSD card adaptor if your computer has an SD card slot, otherwise, you’ll need a USB to SD card adaptor. 

Note: Installing the .img file onto the microSD card was done using a Mac for this project. This procedure will be different if you use another form of operating system such as Windows or Linux. 

Under the applications folder, search for terminal within the utilities folder and open the application. 

PLEASE NOTE: Writing the command dd in terminal can overwrite any partition connected to the Mac, including the main internal storage. If it is done incorrectly the primary Mac OS can be overwritten. It is important all commands are written correctly in the correct sequence from the following procedure.

With the microSD card connected and terminal open, we need to search for the disk number the Mac has allocated for the microSD card. 

Type the command: 

diskutil list

Check the disk number the Mac has allocated for your microSD card. In my case, the mac allocated the microSD card to disk2. 

Next, type the command: 

diskutil unmount /dev/disk2s1

Change the number after disk to match your number allocated to the microSD card. 

In terminal, type the command: 

sudo dd bs=1m if=ImageName.img of=/dev/rdiskNumber conv=sync

So for my case it was:

sudo dd bs=1m if=retropie-4.5.1-rpi2_rpi3.img of=/dev/rdisk2 conv=sync

For this to work, however, I had to first change directory to downloads folder using the command: 

cd downloads

Now terminal writes the .img to the microSD card, which can take up to 15 minutes. Once completed, the following message will be displayed. 

Now safely eject the microSD card and install it into the Raspberry Pi, ensuring the correct orientation is followed.

Plug in a keyboard, mouse and the USB interfaces into the Raspberry Pi, and power on the Raspberry Pi with the micro USB port and it will run the first boot of RetroPie. This will take a couple of minutes then you’ll be prompted with the screen asking to configure a controller. 

For this example, I have used a USB controller, which also works with RetroPie, however, you will be configuring the arcade buttons and joystick which RetroPie will recognise from the USB interface. Configure the buttons and joystick to the format you prefer. 

Finally, configure a hot-key, which will allow you to exit games. 

Using a keyboard, press Shift-F4 to open a terminal menu on the Raspberry Pi. We can now program the power button by running a script. 

Before we create a script, we need to type some commands into terminal in the following order: 

sudo apt-get install python-dev
sudo apt-get install python3-dev
sudo apt-get install gcc
sudo apt-get install python-pip
wget https://pypi.python.org/packages/source/R/RPi.GPIO-0.5.11.tar.gz
sudo tar -zxvf RPi.GPIO-0.5.11.tar.gz
cd RPi.GPIO-0.5.11
sudo python setup.py install
mkdir /home/pi/scripts 
sudo nano /home/pi/scripts/powerbutton.py

Now we have created a script, where we type the following code into:

#! /usr/bin/python
import RPi.GPIO as GPIO
import time
import subprocess
GPIO.setmode(GPIO.BOARD)
oldButtonState1 = True
while True:
 buttonState1 = GPIO.input(3)
 if buttonState1 != oldButtonState1 and buttonState1 == False:
   subprocess.call("shutdown -h now", shell=True,
   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   oldButtonState1 = buttonState1
 time.sleep(.1)

Once again, push CTRL-X followed by Y to save the script. The last thing to do is configure the script to run at startup. This is done with the command:

sudo nano /etc/rc.local

Add this command before the line exit in the script:

python /home/pi/scripts/powerbutton.py &

With a final CTRL-X and Y to save it. 

Now the power button will work, and the relay does not need to be programmed as the GPIO pin will automatically turn off with system shutdown. You will need to load ROMs onto the SD card as RetroPie does not come with any preloaded games.

Note: ROMs are the games you actually play on RetroPie. There are plenty of places to find them. A quick Google of "Games for RetroPie" should get you going.

Forcing the audio to the 3.5mm jack is done through the Settings menu. If you use HDMI as the audio then there's no need to change the settings. That's all there is to it, enjoy your desktop arcade machine! 

WHERE TO FROM HERE?

Further improvements to the enclosure, such as graphics or more lighting is a good way to make the arcade machine more authentic. Using the latest Raspberry Pi is a further improvement, as the one used in this project is the Raspberry Pi 3B.

Build Another! Host an arcade party with multiple machines set up, all built by yourself!

Dean Corva

Dean Corva

University Research Assistant in Electronics