Introduction: Raspberry Pi Arcade Game Emulator in an Atari Lynx

This project is the summation of various similar tasks to use a Raspberry Pi as a portable games emulator. It's heavily indebted to the excellent and fun Adafruit PiGrrl project and DDG's great work to add sound to that project here.

Whilst I was happy with the results of the PiGrrl project, the fact that it used the Framebuffer to output to the TFT screen limited what emulators could run on it. So I decided to try something similar but using a more normal display method of the composite out port and a TFT screen which would allow me to run MAME4ALL, PCSX and various other emulators for things like the SEGA Genesis, Nintendo SNES, MS-DOS and of course the Atari Lynx.

I always liked the Atari Lynx as a device (although I never had the pleasure of owning one as a kid). It's chunky, well-designed and the Atari Lynx 2 is wide enough that it should fit everything in relatively easily. So I thought I'd put it all in one of those.

Three introductory videos showing it in action and giving an overview of the project are above.

Apologies in advance for the lack of decent work-in-progress pictures as I'm writing this instructable retrospectively. However as most of the components are from Adafruit and the whole thing is heavily based on the PiGrrl project, those pages make useful guides as well.

Step 1: Hardware Components

1.) Atari Lynx (not working). I got mine from eBay available here. It's useful if the speaker still works as it can be re-used, but not essential. If it's not working when it arrives, you can always just buy another one for a couple of bucks. The rest of the old Lynx internals won't be used so if the screen's busted for example, it doesn't matter for this project.

2.) Raspberry Pi B+ available here. I used the B+ as the power consumption is supposed to be better and I obviously had more pins to play with.

3.) Adafruit Powerboost and Recharger available here. This allows the 3.7V battery to power the entire thing at 5V and also supports the recharging interface to a micro-USB cable. It's a nice bit of kit.

4.) Adafruit Lipoly battery, 3.7V and 2500mAh available here. I picked this as it's nice and flat so fits in the case nicely and offers a nice amount of power for the size and price.

5.) Adafruit breadboad friendly SPDT switch available here. As we won't be using any of the existing Lynx board we're going to need a new power button. This works nicely with the Powerboost/Recharging board above.

6.) Adafruit Stereo 2.8W Class D Audio Amplifier TPA2016 available here. We'll need to amplify the sound output from the Pi's composite audio/video out port and route it to the speaker. This is a nice board for this I think.

7.) **Optional if the on-board speaker doesn't work on the Lynx**. A Mini Metal Speaker w/Wires - 8 ohm 0.5W available here. The Atari Lynx speaker is preferable as it's quite good and fits nicely in the case already. If it doesn't play ball then you might want to get a couple of these or an equivalent to take its place.

8.) Raspberry PI B+ GPIO 40 pin ribbon cable available here. We'll plug one end (make sure it's the right end) into the GPIO ports of the Pi, and cut the connector off the other end. We'll split the wires out on that end and solder them to the Lynx FPC connector (for the buttons) and the Powerboost (for the power).

9.) **Optional and only required if you can't use the one that came with the Lynx** 14 pin 1.25mm pitch FPC connector available here. When I removed the FPC connector on the Lynx's original board, I bungled it completely and ruined the connector. So I had to buy another one which took some guessing as I wasn't sure of the pitch of the Lynx's FPC. After some trial and error this connector worked fine.

10.) 5V 3.5” TFT LCD screen available on eBay and Amazon etc.. I got mine here. Important note: I was lucky in that this monitor worked fine with a 5V input. However most seem to require 12V by default and that won't work for this project which is powered using 5V only. If your screen doesn't power up or flickers and clearly requires 12V then please consult these great guides on how to bypass the regulator on the monitor's control board so it works with a 5V input here and here.

11.) Edimax wireless dongle available here. After the software's been installed and it's all working you can remove this if you like, but it does still fit in the case even if it's left attached to the Pi. I've just left mine attached.

12.) A Raspberry Pi B+ compatible 4 pole 3.5mm Jack to RCA composite cable to connect the PI to the LCD and the amp for sound and vision. One is available here although that's quite long so you might want to get a shorter one. We'll be cutting off the red, yellow and white plugs anyway to solder them to the amp and LCD.

13.) A micro SD card for the Raspberry Pi available here. If you want to use a lot of Playstation games you should consider a 32Gb model.

Step 2: Software

1.) The main emulation front end I used is the excellent PiPlay from Shea Silverman. It works really well, has a good support community and is easily configurable so you can add other emulators or software easily.

2.) PiPlay comes with the retrogame program which runs in the background and converts button presses to keyboard presses so games can be controlled from the keypad and buttons on the Lynx. The original came from Adafruit here but there's an improved version here by Ian57 which I used and which allows a greater combination of key presses.

3.) Game ROMs and game software. I can't direct you to them for copyright reasons but a quick Google will yield a cornucopia of great games for whatever platforms you want.

Step 3: Remove the Old Lynx Components

A good visual guide on how to take out the components is from MrSiggler and is here. Below are the steps from that guide which we're interested in.

1.) Turn the Lynx over, remove the plastic grips (they're just glued on and can be reattached later).

2.) Unscrew the screws and remove the back.

3.) Remove the screw from the battery compartment and gently lift the main board to allow the battery compartment to be removed.

4.) Remove the ribbon cable (aka flexible printed cable or FPC) by lifting the connector bar and removing the ribbon. Be very careful *NOT* to just pull the ribbon out as it will scrape off the connector printing and ruin the FPC.

5.) Unclip the speaker cable from the main board and remove the speaker itself from the case. You can use a knife to pop it out from its housing. It will be replaced into the housing once we've built the whole circuit and we're ready to insert everything back into the case.

6.) Unscrew the old screen from the front panel.

7.) If you like you can try to desolder the FPC connector from the main Lynx board. As mentioned above I tried this, failed miserably and had to order more FPC connectors to replace it. The pictures above show what the board looked like and the piece itself after I had messed it up. But a replacement doesn't cost much.

All you should have left now is the FPC nicely in place in the front of the case under its housing, the speaker removed from the housing for later use, the back of the case which is empty and the battery compartment which we probably won't need again as it doesn't fit back in after we've put the Pi etc. inside.

Now we're ready to start building the circuit.

Step 4: Connect the New Components - Battery and Power Boost

1.) The battery will connect to the Powerboost board via the JST connector.

2.) Solder the on/off button to the EN and GND pins on the board. After you've done this you might want to connect the battery and test the on/off button. If it's all working the LEDs on the PB board will switch on and off.

3.) The + and - pins at the head of the board are where the other components will be soldered to i.e. the amplifier, the LCD and the PI.

PI - Solder pin 2 from the PI to the -ive pin on the Powerboost board. Solder pin 6 from the PI to the +ive pin on the Powerboost board.

Amplifier - Solder the VCC pin from the amp board to the +ive pin on the Powerboost. Solder the GND pin from the amp board to the -ive pin on the Powerboost.

LCD - Splice the power lead from the LCD to another wire to increase the available length and solder that to the +ive pin on the Powerboost. The wire is normally colored red but check the specs of you monitor to make sure. Splice the ground lead from the LCD to the -ive pin on the Powerboost via an extra wire. The wire is normally colored black but check the specs of you monitor to make sure.

Step 5: Connect the New Components - Amplifier and Speaker

1.) Solder the speaker to one of the output pairs on the board.

2.) If you haven't already done it from the previous step, solder the VCC and GND pins over to the Power Boost +ive and -ive pins respectively.

3.) Take the audio cable from the RCA plug and solder that to the input pin on the amplifier board. This thread is useful to help determine which of the 3 RCA cables is audio but it's usually red for right audio and white for left audio. I used red and left white unconnected.

Step 6: Connect the New Components - LCD Screen

1.) On this LCD, the red wire was +ive, the black wire was ground and the yellow wire carried the video signal. The white wire was not used. If you haven't already please refer to the Powerboost section of this tutorial to see how to wire the screen for power.

2.) Splice the yellow cable, or whichever wire on your LCD carries the video signal, to the video wire of the RCA jack from the PI. As per this thread the video wire on the RCA cable is also usually yellow.

3.) Test it. Try connecting the battery to the PowerBoost and switching on the on/off button. The LCD should light up even if there's no actual signal. If not, try switching on the PI, making sure the RCA jack is in the composite output port.

You should get output on the LCD screen now. If you don't please double check the soldering and the wiring.

If the screen flickers and dies, then you may need to bypass the voltage regulator on the chip. See the links in the Components section for more details.

Step 7: Connect the Components - Attach the Pi to the Lynx FPC

1.) Now we need to connect the existing Lynx wiring i.e. the buttons, to the Pi. I probably found this the most complex part of the project but that's because my soldering skills are mediocre at best as you can see from the screen shot.

First of all connect the GPIO ribbon able to the Pi's GPIO, if you haven't already. Make sure the white ribbon is aligned to pin 1. Cut the header off the other end of the ribbon and pull the individual wires apart a few inches down to allow each pin to be soldered separately.

Then connect the FPC connector to the flexible cable on the Lynx, gently pushing the latching mechanism down to secure the cable.

A gentleman called Richard Blackman, who has done a similar project to this, did fantastic work figuring out which pin on the Lynx FPC did what. The link to his project is here and we are particularly interested in the table above.

In my retrogame.c mapping (the program that tells the Pi what button is supposed to do what) I have:-

{ 2, KEY_UP }, // Up
{ 3, KEY_DOWN }, // Down

{ 4, KEY_LEFT }, // Left Joystick (4 pins)

{ 17, KEY_RIGHT }, // Right

{ 27, KEY_LEFTCTRL }, // Button 1

{ 22, KEY_LEFTALT }, // Button 2

{ 10, KEY_X }, // Button 3

{ 9, KEY_Z }, // Button 4

{ 11, KEY_SPACE }, // Button 5

{ 5, KEY_ENTER }, // Button 6

{ 6, KEY_1 }, // Button Start P1

{ 13, KEY_5 }, // Button Coins/Credits P1

So if you want to follow something broadly similar you'll need to solder those GPIO pins (the number in the first column) to the relevant Lynx FPC pin as defined in the table. Note the numbers in retrogame denote the GPIO number not the pin number so you may need to use a mapping table to get to that. One is above which is hopefully helpful.

For example, I soldered GPIO 2 from the Pi to 12th pin on the Lynx FPC, matching the up button of the Lynx to the GPIO pin retrogame expects to indicate 'up', and so on.

Step 8: Package Components Into Atari Lynx Case

One of the pictures from the introduction section shows the Lynx case open with everything packaged within it. You can use that as a rough guide if it helps. To fix the components I used low-tech double sided sticky mounting pads but feel free to use a hot glue gun if you prefer.

1.) Place the speaker back in its housing. It's fine if the amplifier board is hovering above it.

2.) Place the LCD over the acrylic cover so it's square on, with none of the borders showing. You will lose a couple of millimeters of the visible LCD at the top and the bottom unfortunately but it doesn't impact game play too much.

3.) Place the Pi to the right of the case (as you look at it from the back) and have the GPIO ribbon cable flow to the left in the direction of the Lynx FPC cable and Powerboost. If you've already soldered this it will reduce the strain and is the natural direction. If you've yet to solder it then it will make soldering easier obviously.

4.) Place the Powerboost near the top of the case with the USB socket facing up towards the top of the case. I placed it in the mouth of the headphone jack as that was the only hole already wide enough to take a USB cable with no modifications.

Glue this in place firmly bearing in mind that it will undergo significant force when people repeatedly attach and detach the charging cable.

5.) I placed the on/off switch in the 'brightness' knob hole, but the hole wasn't quite wide enough so I crudely cut chunks out of it to widen the hole. I then glued it in.

6.) Place the battery flat against the case, just to the left of the LCD screen. The amplifier board sits just above this.

7.) Tie/stick the cables as best suits your installation.

8.) Place the back cover over the front, screw it in, taking care not to screw through any wires or force anything. Turn it on and assuming it powers up, leave it running and check for any burning smell and/or components getting too hot.

If that occurs, switch it off, open it up and reposition the affected component.

When you're happy you should be good to go! Enjoy!

Step 9: Issues and Improvements

I couldn't get the "On" button to work and I notice that Richard Blackman also left it off his ribbon mapping table so I wonder if this can't just be wired to a GPIO port for some reason (although it may just be my soldering)? If you can get it to work it's worth doing as we're limited on buttons on some emulators (e.g. PS1) so the more we have to play with the better.

The amplifier I used didn't support volume control, only gain control. If you would like to introduce support for that check your favorite electronics site for an amp that supports volume control and which supports I2C. That way you could hook it into the Pi and write some Python to allow it to be controlled by either a potentiometer or a combination of buttons (with the additional combination configured into retrogame.c).

It would have been nice to pipe the LED output from the Powerboost to the existing LED output hole on the front of the case. I ran out of time to do that unfortunately.