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 http://www.austinamusements.com.au 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 https://github.com/markpudd/gate_opener.   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.


Gate Opener

I’ve posted a new project to github (https://github.com/markmoro/gate_opener).   The aim of this project is to make my driveway gate open as I drive up to it.   It works by using geo fencing on my phone to detect that I am close to my house and then send a message to an Arduino with ethernet shield to open the gate.   The opening it self is done with a spare gate remote that has had the switch replaced with a MOSFET.   This project is still in progress.

The key thing about this project was to make sure that only some one with a correct code can open the gate.   To do this there is a few steps:-

  1. Both the Arduino and the phone have a shared secret key
  2. The phone requests a token from the Arduino
  3. The token is appended with the command (‘open’ string) and an HMAC digest is created with the token
  4. The digest is sent as a POST parameter to the Arduino
  5. The Arduino re-creates the digest and verifies the received digest matches
  6. The gate is open (sends a 500ms pulse to the MOSFET gate to open the switch).

The above scheme should prevent any replay attacks as all of the requests are unencrypted (there is no SSL for Arduino).    There is also a test Python bottle server and test bash scripts to test both sides of the communications (in the webapp folder).

There has been a few issues with the MOSFET circuit which I will fix in the next few days and post!

LCD Display with Backlight

There is a tutorial and code on the Arduino site on how to  use a 74HC595 shift register  to control a LCD Display here http://playground.arduino.cc/Main/LiquidCrystal.  The Garden Station project uses a modified version of this library which adds the facility to add a second shift register for a second set of outputs, which I used to control the LED statuses.  I’ve also used the QC pin to control the backlight via a MOSFET.   As part of this I added a few extra methods (void setSecondPins(uint8_t secondPins),backlightOn() and  backlightOff() ).   The code is checked into github:-


The garden station code has also been updated to use this code.



I ordered a USBtiny a few weeks ago from ebay to use to program the garden station and it arrived today!


Got it up and running an it works great!  I was previously using a spare Arduino Uno board but this new programmer is simpler and doesn’t require a bunch of jumper wires via a bread board (also frees up the Arduino for something else).   The power also seems to work to power the board via the programmer.

I had to bend back the spare data pins on the prototype board (they were right next to the ISP pins), however I’ve already moved them on the SMD version of the board.

Garden Station

As mentioned on a previous post here are a few more details on the garden station project.   The aim of this project is to build a simple garden watering controller.  As part of this I also wanted to get some PCB’s made to try out getting some made and a sent to me.   I used seeed studio to get the PCBs made and they came out great (although they do take about 4 week to get).

The basic premiss of the garden station is that there are 5 watering sensors, a temperature sensor, 5 servos (used to control water), 6 LEDs, 3 buttons and an LCD display for setup.   I’ve also added ICSP with 2 extra pins to allow for ethernet or SD card expansion via SPI.  On the final version which is not yet built there is also a MOSFET to switch on and off the LCD back light.  I’m building a few of these boards and will probably use them as general purpose control boards for other projects.

The circuit diagram, PCB layout and code are available from github.

I’m still in the middle of this project but have a working prototype from the original through hole PCB:-


As you can see there is some hacks on the board around the shift registers as there were some error on the original circuit (confusion of Eagle’s 595 pin names..).

The working of the circuit is reasonable simple.   6 of the analogue pins are used to provide the input for the moisture sensors and temperature.  I’m using 2 nails which there are plenty of internet articles about.   These go to the screw connectors at the bottom right.

There are 5 PWM outputs to control the servo valves.  These are the bottom middle connectors on the picture above.  I use a small break out board to connect the servos which are all located together.   My original plan was to run long wires to near the plants but in the end I decided to keep them all next to the board (its currently all in an Ice Cream tub…).   The servo are connected to some Pope valves which connect to small 4mm hoses.   These are attached together with a hot glue gun and some paper clips agh the moment, although I’m getting a friend to 3D print some proper brackets:-


I’m also looking to direct drive via a cog when the mounting bracket has been made.

Display and Buttons

At the top of the board there are some connection for the display and the input buttons.   These are not the same as a standard display pinout on the original prototype (hence the wire soldered straight in).   On the SMD version theses have been fixed.   The display is controlled via the first shift register in order to reduce the number of pins needed.


The second shift register controls the LED’s on the board and uses the overflow from the first (hence no extra pins needed).  The last two outputs on the second shift register are used to control the backlight and provide the power for the moisture sensor in the SMD version.

Finally there is a set of 8 pins used for ICSP (6 pin with the 2 top pins being extra data output intended for SPI ethernet or SD card).

I’m still testing but will post some video of the prototype running in the future.   I’ll also be ordering all the parts for the SMD version in the next week so will post the details when thats done!