Arcade Controls

The Raspberry Pi arcade now has controls!


The controls have been connected to an Arduino which then uses SPI to connect to the Raspberry Pi.   The following hardware design was used:-


Its important to use a logic level converter for the 5v to 3.3v conversion.

After hunting around for good ways to simulate key presses on the Pi I stumbled across the Adafruit retrogame code which uses GPIO as inputs.   I’ve forked this on github and changed it to request the state of the buttons over SPI and update the presses.  It currently polls and doesn’t seem to be using much CPU, although it would be possible to use a separate GPIO pin to tell the Pi that there is a change in state.   The code is available at   This also includes the Arduino code to connect the inputs too.

The SPI protocol basically send an 0xFF command to the Arduino which returns 3 byte, which are P1 status,P2 Status and Aux Status.   The Aux status is used for P1/P2 button and the coin mech.

I’m currently building an input board to replace the Arduino which is basically the ATMega broken out with some connector for P1/P2 and aux.   I’ll publish this at the end of the week.

I also added some audio amplifier and speaker this week.  There is still a bit to do on this project such as getting some artwork printed, painting the cabinet and fixing up the monitor mounts!




Raspberry Pi Arcade

I been considering build an table top arcade cabinet for a while.   Since I’ve had some spare time lately I decided to start a project to build one.  I wanted to use as much stuff that I had around to keep the cost down so I decided to use a Raspberry Pi for running Mame, an old VGA monitor, some spare particle board and an old ATX power supply.  I’m also keen to have the potential to change to a JAMMA board or old PC in the future.

For the cabinet I looked at a few internet designs (weeCade and some others) but decided in the end to just create a rough sketch in 123D and build based around the size of the monitor I had.


The next thing to do was to order in some arcade controls.   I used and ordered their $30 bundle and a $17 coin mech.  I fitted a one player control board to just get things up and running.   I also needed to get a HDMI/VGA converter which came from ebay.   For audio I’ve used a cheap 1W amplifier kit and two 1W speakers.  


Time to wire the Pi up with the monitor and audio and have a quick test.   For the test I have not wired up the control surface so wss using a keyboard.   The Cameleon Pi distro has Mame installed so it was pretty easy to get up and running.   I had to changed the HDMI mode to 2 in the /boot/config.txt which fixed the audio out (from the HDMI adaptor) and as I was change the config I also increased the over clock to 1Ghz.   At this point everything seems to be working apart from the controls!ImageImage


The test control surface is built but not interfaced to the Pi.  I’ve had a few ideas on ways to do this:-

  • Buy a USB keyboard control surface interface.   There is some boards available for this purpose or the other option was to try and make one from an old donor keyboard.  I don’t have a donor keyboard and I didn’t want to buy the convertor.
  • Interface the controls directly to the GPIO on the PI.   This was my original though cut to it being reasonably simple however there is a limited number of pins.  For a 2 player, 3 Button controller with P1/P2 buttons and coin mech I’de need 17 inputs.
  • Using an IO expander IC on SPI.  This wasn’t a bad idea but I need to order in some expander IC’s…
  • Use an Arduino to control get the inputs and convert to SPI.  This is option I’m going to go with as I have all the parts.   I am short one input as I am using an UNO so will put the coin mech either on a Pi GPIO or make it use the same as P1/P2 pressed together which would also allow adding credits without using coins an alternative would be to use multiple inputs on one analogue input using a resistor network.  Using the Arduino also has the advantage of allowing extra features easily (such as auto fire) and has analogue inputs if required.

As I chosen to run with the Arduino solution I’m currently doing a little research on how to get SPI working between Pi/Arduino which I’ll post on once working!

I’m also looking to get a backing printed for the control surface which I will then cover with some clear plastic sheet.



Back from Holiday!

I’m back from holiday and have updated the gate opener code.  I’ve changed my github username so the code is now at   There is a few changes:-

  • Added an iOS client.  This is pretty basic (no design) but has a button to open and a geo-fenced area to allow the opening to happen automatically as you get near to the gate.  In the setup you can add the shared secret for the Arduino and set the centre of the geo fence.  The fence is set to 8 meters at the moment but I’ll look to add a slider to widen this in the future (a non round geofence would also be cool).
  • Fixed up the Arduino code.   On review of the Arduino code today there was a lot of issues.  These included invalid checking, not reading the post parameters correctly and few other issues.   I’ve fixed these up now however the code needs tidying up.  The code was originally based on the example web server for the Arduino Ethernet shield which I think has caused some issues, if I have some time I’m going to re-write from scratch…..

I’ll post the hardware pictures in a future post.