ZX Spectrum USB Adapter for Raspberry Pi RetroPie Builds

10,764

35

8

Introduction: ZX Spectrum USB Adapter for Raspberry Pi RetroPie Builds

About: Writer for Hackster.io, Hackaday.com, and others. Author of Idiot's Guides: 3D Printing and A Beginner's Guide to 3D Modeling: A Guide to Autodesk Fusion 360.

RetroPie is a special Linux distro that is designed specifically for emulating retro video game systems on Raspberry Pis and other single-board computers. I've been wanting to go all-out on a RetroPie build for a while now, and when I saw that reproduction Sinclair ZX Spectrum were available I knew they would be perfect.

It would have been simple enough to cram a Raspberry Pi into the case, but I wanted the ZX Spectrum keyboard to be functional. That's why I designed this USB keyboard adapter board. The standard ZX Spectrum keyboard ribbons plug into the adapter, and it connects to any keyboard as a standard USB keyboard. There is also a DC barrel jack to supply power to the Raspberry Pi and to an optional fan.

Supplies

For the adapter:

For the entire RetroPie build:

Step 1: Program the Teensy 3.2

Upload the provided Arduino sketch to your Teensy 3.2. When you upload the code, you have the option to configure your Teensy 3.2 to as a USB HID. This will ensure that computers automatically recognize it as a plug-and-play device. In this case, you want it to show up as a USB keyboard. To do that, make sure you sketch is open and ready to upload. Then select "keyboard" from the USB Type submenu in the Tools menu. Then upload your sketch as you normally would with a Teensy board and proceed to the next step.

A quick note about how the keyboard matrix is handled: the ZX Spectrum keyboard is obviously a lot different than a modern keyboard. It has far less keys, punctuation and special characters are in different places, and special functions (like "Print") are used by default when you're in BASIC on the real ZX Spectrum. For that reason, I have made a number of compromises for usability.

Take a look at the keyboard matrix layout in the attached image. With that as a reference, you can edit the Arduino code to send whatever key press you like when a physical key is pressed. It's a standard keyboard matrix, and in the code I have columns labeled A-H and rows labeled 1-5.

Step 2: PCB Design and Fabrication

Get PCBs Fabricated:

You can find the complete Gerber files in a .zip folder at this link: https://drive.google.com/file/d/1BaLNvOiBaTPo4T3Lt...

You can have the PCBs fabricated by whichever service you prefer. I used JLCPCB, as they're affordable, quick, and the quality is great.

Notes on PCB Design:

I designed the PCB using KiCAD, which is fantastic open source design software. It does have a steep learning curve, but there are many tutorials online. Once you get the hang of it, it's quite powerful.

I started by taking measurement of the reproduction ZX Spectrum case. I created a simple sketch of the mounting hole locations in Autodesk Fusion 360. I then created a simple 3D model of the basic outline of the PCB. My two main goals were for the PCB to fit and mount the PCB without any modifications, and for the two ribbon connectors to be placed appropriately. I then exported the outline of the PCB to be used within KiCAD.

In KiCAD, I started by creating my schematic. Then I started creating the actual PCB layout (using the DXF board outline). After placing all of the components and routing the traces, I decided to get creative with the artwork. The bottom of the board is covered in silly text, and the top has some graphics. "Resist!" plus a fist next to the resistors for giggles, and stripes on the corner to mirror the stripes on the ZX Spectrum case.

Step 3: Assemble the PCB

This step should be very easy if you have basic soldering experience. All of the components are through-hole and easy to solder. Make sure your Teensy 3.2 has all of the outer header pins in place. Not all of them are actually used, but it's easiest just to solder them all. The resistors don't have a polarity, so you don't have to worry about the orientation.

After all of the components are in place, use some snips to trim off the excess from the pins on the backside. This will ensure that the PCB lies flat when it is inside of the enclosure.

Step 4: Install RetroPie

Before moving onto final assembly, it's best to setup RetroPie so you can test everything.

Download the latest RetroPie image from this link: https://retropie.org.uk/download/

Burn the image to your SD card using a utility like Etcher. (https://www.balena.io/etcher/)

Insert the SD card in your Raspberry Pi, plug in the wireless controller receivers and the USB cable to your adapter board, the HDMI cable to your TV, and then connect power.

Follow the setup steps to configure RetroPie. Afterwards, you can follow the standard steps (documented on the RetroPie website) to setup whichever emulators you want to use and copy your library of ROMs.

The ZX Spectrum emulator is quirky, and it's tricky to get it working with any keyboard (this one included). This link provides some advice: https://retropie.org.uk/forum/topic/16119/keyboard...

You will likely need to do some tweaking to get everything working properly, but that's the case with any keyboard.

Step 5: Final Assembly

The final assembly is straightforward, but you may want to take another look at my video to see how everything should fit together. You'll solder two wires from the 5V and GND Raspberry Pi pins to the power terminals on the PCB. Then plug the short right-angle USB cable from the Teensy 3.2 to the Raspberry Pi. The HDMI extension cable should run from the HDMI port out the back of the case. Finally, plug the ZX Spectrum keyboard ribbon cables into the connectors.

If you want to, you can use hot glue or double-sided tape to secure the Raspberry Pi in place, but it's not necessary (everything is pretty snug). While being careful to keep the PCB in place, push your screws through the bottom of the case, through the PCB holes, and then thread them into the mounting holes. If anything binds, then adjust the position of the Raspberry Pi and/or the USB and HDMI cables, then try again.

That's it! Just plug in your power cable and HDMI cable and start gaming!

PCB Design Challenge

Runner Up in the
PCB Design Challenge

Be the First to Share

    Recommendations

    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Teach With Tinkercad Contest

      Teach With Tinkercad Contest
    • Fandom Contest

      Fandom Contest

    8 Comments

    0
    BadMojo
    BadMojo

    3 months ago

    Hi Cameron,
    Many thanks for the awesome PCB design, I've just received some from JLCPCB (as above there are no screw holes but it's nothing a little precision drilling won't fix)
    One small question : Teensy 3.2's are quite hard to get hold of at the moment, do you know if a Teensy LC or even a Teensy 4 would work instead?

    Cheers.

    0
    CameronCoward
    CameronCoward

    Reply 3 months ago

    Aw dang, that's so weird that the holes aren't showing up! I have no idea what is causing that problem... Did you upload the entire zip folder that contains the drill file?

    I believe both the 4.0 and LC would work, but I haven't tried it and so I'm not positive. Both of those can be configured to show up as a USB keyboard, like the 3.2. And they have similar pinouts/footprints. Worst case, you might need to change the pin numbers in the code, but I think it will work.

    0
    BadMojo
    BadMojo

    Reply 3 months ago

    Yes I uploaded the zip just as it downloaded from here.

    Ok cool, I'll order a LC first and try. It'll be a learning curve if I have to try and alter pins as I've never done such a thing before. If it works, I'll report back here so others can see.

    0
    CameronCoward
    CameronCoward

    Reply 3 months ago

    Sounds good! Feel free to send me a message if you have any questions!

    0
    AlanMacniven
    AlanMacniven

    Question 10 months ago on Step 2

    Hi Cameron,
    This looks like a great project. Thanks for sharing!
    I've been using an empty Spectrum case as wall art, but thought I might as well take the plunge and fit it with a Pi - following your lead. I've never had PCBs made up before, and was suprised how cheap they were. However, the first batch have just come back without the two mounting holes I can see in your pictures. Any tips or suggestions as to what I might have done wrong? I have all the other bits now, and am keen to get the boards sorted so I can get it all soldered up and mounted.
    Thanks,
    Alan

    0
    CameronCoward
    CameronCoward

    Answer 10 months ago

    That's definitely strange! Which company did you order the PCBs from?

    Are the hole locations marked, just not drilled? If so, you might be able to drill the holes yourself.

    0
    AlanMacniven
    AlanMacniven

    Reply 9 months ago

    Hi Cameron, and thanks for getting back to me. I used a site called JLCPCB. I wonder if there's an issue with their drag-and-drop software? I checked again, uploading the whole zip folder. But it didn't show the mounting holes. Maybe I'm missing a step? I can always have a go at drilling them myself. Had to get five of them to run the order, so I've got a few spare!

    0
    CameronCoward
    CameronCoward

    Reply 9 months ago

    JLCPCB is a good company, I actually used them when I made the boards in the pictures. I used the exact same ZIP folder that I uploaded here, so I have no idea why the holes aren't showing up. That's very strange. I wish I had an explanation for you! Maybe the folks at JLCPCB can help.