Complete Arduino-based 3D-printed Battery-powered Mini Retro Arcade Machine

by berlingozzo in Circuits > Arduino

5306 Views, 63 Favorites, 0 Comments

Complete Arduino-based 3D-printed Battery-powered Mini Retro Arcade Machine

FQEN3CYKUV8UFRI.jpeg
Arduino-based 3D-printed mini retro arcade machine

It's been a while since I've published my last Instructables. I'm back, and I'm 3D-printed-powered!


Enjoy this mini retro arcade machine. It's literally my first complete end-to-end 3D-printed project: I made the design, printed it, assembled the electronics, programmed it, and now to the tutorial :)


This guide will be updated soon with instructions to finish the print with sanding, filler, and paint. Also, I'll keep adding games.


Notable features:

  • 2 players
  • Battery powered
  • Retro buzzer sounds taken directly from the GameBoy intro, Nibbles.bas, War Games
  • Sporting a shiny Black Led Plexiglas bought directly from the factory
  • Optimized Led separation and diffusion


Supplies

20211017_103425.jpg
20211017_103755.jpg
20211017_103856.jpg

The project needs:

  • a bunch of 3D-printed parts (STL attached below)
  • a bunch of electronics (Arduino Uno clone, Led matrix, dual PS2 joystick shield, piezo buzzer, battery holder, assorted cables and connectors
  • a diffuser for the Leds

Complete bill of materials:

  1. Arduino Uno clone. I used the "dccduino", 10$ from Aliexpress: https://www.aliexpress.com/item/32256247770.html
  2. 8x8 Neopixel (ws2812b) Led matrix (clone). I used this, 6$ from Aliexpress: https://www.aliexpress.com/item/4001296811800.html
  3. Dual PS2-style joystick shield. I used this, 3$ from Aliexpress: https://www.aliexpress.com/item/1005001632478611.html. Warning! Buy 2 of these, for two reasons: mine came with a shorted AREF pin; they have an extra piece of PCB in random places and you need its design to fit the 3D printed part. Buying 2 will maximise the likelihood of success.
  4. Piezo buzzer. I used one similar to this, 1$, from Aliexpress: https://www.aliexpress.com/item/1005002531465180.html
  5. Battery holder. I used one of these, they're 4 for 10$ on Aliexpress. These are switched! https://www.aliexpress.com/item/32717063169.html
  6. Assorted dupont cables, 4-way dupont connectors, electrical junctions, speaker cable. I had spare ones around. In general, any cables to bring power from the battery holder to the leds and the arduino, which you are comfortable soldering and / or connecting. I'm terrible at soldering, so you shouldn't take my advice on this :)
  7. What I consider the real star of the hardware: a piece of Black Led Plexiglas coming directly from the factory in Germany. You could try also the Adafruit one. I used this, 10$ for a 30x20cm sample, out of which I could cut 6 pieces like the one needed for this project: https://www.plexiglas-shop.com/ie/products/plexiglas-led/pl9h001gt-3-00-3050x2050-b-sh-01-black-white.html
  8. The attached STL files for the 3D printed parts.

Electronics: Soldering and Connections

20211017_110815.jpg
20211017_164054.jpg
20211017_170120.jpg
20211017_110530.jpg

We need to do the following:

  • prepare the battery pack (comes unsoldered)
  • connect the Arduino to power, leds, and buzzer
  • connect the leds to power

All while being mindful of the fact that we need to route cables through the various 3D-printed parts. If you use dupont cables everywhere, it's easy to disconnect/route/connect.

First, take your battery pack and notice it has a few metal connectors coming out of the battery holder. Only two are electrical connectors, the other ones are just there to hold things together mechanically. Note the largest two connectors also correspond to the big + and - signs on the plastic. Tin the two connectors with solder. Notice then the on/off switch. It's a three pole one, which means we can connect the middle pole to the +, and then one of the two sides will be going to the electronics to power. If you're unsure, use a multimeter with continuity test to check the connections before soldering. Tin the two poles. Solder a wire from the - of the battery pack (I use speaker cable, all white, with the ground marked with a black line). Solder a wire from the + of the battery pack, to the middle pole of the switch. Solder a wire from the side pole of the switch. For convenience, you can now plug these two wires into an electrical junction (that white element in the pictures).

For the Arduino, we need to bear in mind which pins the ps2 joystick shield is going to use. Looking at the PCB, it looks like it's using some analog pins, then D2 and D4 (for the push buttons of the joysticks), then another pin for the led. Which means a good few digital pins are free to use. I've selected pins 7 for the led matrix, and pin 8 for the buzzer.

Then, solder some wires going from pins 7, 8, 5v, and GND (I've used the side pins for power as they were giving the full 5.16v. For convenience, if you have a spare 4-way connector (from another led matrix / strip), you could wire: the white to ground; the red to 5v; green to 7; blue to 8. This way, tests and repairs are easier (as you can see from the images, one Arduino died and I needed to replace it - using the connector it's a piece of cake).

For the leds, I'm used to powering long (5m) strips, so I know by experience that it's better to try to use all the power cables to spread the power and reduce voltage drop across the leds. So I've connected the red/black power wires in the middle of the matrix directly to the white electrical junction, and then I used the 3-way connector for 5v/data in/GND to the arduino, using another 3 dupont cables.

Finally, I connected the piezo buzzer: GND (black) to any GND you have in the system (again I used the white connector), and red to pin 8 of the Arduino. To do this, I soldered a dupont cable to the red wire of the piezo, and then plugged it to the blue pin on the 4-way connector coming from the Arduino.

Enough with the wiring!

Electronics: Programming

Screenshot 2021-10-18 at 01.42.00.png

If you're new to Arduino programming, I suggest you start with a basic tutorial on Instructables.

This step assumes you are familiar with the Arduino IDE and how to program an Arduino-compatible board.

What you need to do is to install these libraries:

  • adafruit_neopixel
  • adafruit_gfx
  • adafruit_neomatrix
  • alignedjoy
  • ezBuzzer

Adafruit Neomatrix makes it very easy to work with these led matrices. All you need to do is to properly set them up in the code, and then you have several primitives for drawing pixels, lines, rectangles, etc.

The only limitation I find very annoying is the uint_16 format to specify colors. Right, so, 16 is not a multiple of 3. This means you can't simply use, for example, BBBBBB for grey. Nope. Out of the 16 bits, the first 5 are for red, then 6 for blue, then 5 for green. Apparently our eyes have different sensitivity to different colors. In practical terms, it's advisable to define a bunch of colors after finding their codes online, and then stick to those colors only.

I found this tool very useful: http://greekgeeks.net/#maker-tools_convertColor

Next, the joysticks. I've tried several options, including reading the raw analog values , and I converged to this alignedjoy library. It does a good job, however I struggle with perfect calibration, so I just set two thresholds, 400 and 600, to decide whether you're outside of the joystick's middle position.

Last, but definitely not least, my favorite bit of the software: the ezBuzzer library, and the way I used it :)

If you're not new to the Arduino, you know that you could generate a square wave at a particular frequency, feed it to the piezo buzzer, and produce a sound. However, most people use (delay) to produce notes. This may be ok for notifications, but it's not ok for sound effects in games, as the delay is noticeable during the gameplay. You'd need to set the buzzer on, and then check within the main loop() if enough time has passed, before shutting the buzzer off. What ezBuzzer does for you is to simplify all of this, giving you de facto a non-blocking musical library using the piezo buzzer, with the addition of pre-defined notes!

Next, the not-so-young me, wanted to give this machine a real retro flavour. I've found the original notes used in the gameboy startup animation, the sound effects of the '90's Nibbles.bas, and even the frequency of the buzzers for the two players of tic-tac-toe in the War Games movie! :) they are all in the code.

The code would need a bit of cleaning, but it works. You have three pre-defined games, and it's easy enough to add more, just follow the lead on the loop() function logic: snake for 2 players (without walls given the limited game area), tic-tac-toe, and snake for 1 player. Next games I'll add include connect 4 (or 4-in-a-row) and - if you're good with memory- even chess is possible! You'd need to color-code each piece..

Upload the attached code to the Arduino and you're good to go.

Bonus feature of the gameboy startup animation: it gives you a guide for orienting the matrix in later steps (assemling)!

Downloads

Preparing the Plexiglas

20211014_134839.jpg
20211014_140806.jpg
20211014_141533.jpg
20211014_142837.jpg

Plexiglas, or acrylic, is not the easiest material to work with. I am not used to cut it, and I was really afraid of this step. Thankfully, I had several options and had seen various guides online for cutting it.

First, you need to hold it firmly, I strongly suggest using clamps. I only had small and weak ones, so I used a rigid metal guide to spread and direct the force.

I measured 90mmx90mm. The led matrix is 80mmx80mm, so an extra 5mm all around it would give enough clearance for piece of mind.

Then, I started with the first approach: scoring using the guide with a cutter / sharp blade, then firmly pulling down one part, hoping the two parts will separate nicely without cracks. I'm not entirely sure why this approach didn't work. I suspect it's because of the thin plexiglas I was using (3mm), and the relatively small piece to be cut.

So I went to approach number two. Using the scoring as a guide, I started cutting with a coping saw. Never again. Not only it's very slow, but it was difficult to follow the guide and I ended up wobbling a bit and not producing a straight cut.

This is when I remember I am now the proud owner of an excellent oscillating multi-tool, which I used to cut through a door frame! Using the wood+metal blade and the slowest speed, I gently and precisely followed the guide and the cut was as straight as it could be. Only issue: the plexiglass edge had melted! First, remove the melted plastic from the blade as soon as you can, before it cools down. Second, worry not: take a sanding block with 180grit sandpaper and start sanding perpendicular to the edge, basically trying to force the melted plastic away from the sheet, by sanding with a 45 degrees angle. Then sand parallel to the edge to make things extra smooth. I was extremely happy with the final result. A further pass with 240 and then 400 would have left me with the same clean cut from the factory, however again I couldn't care less as we have 5 mm of clearance! :)

When sanding plexiglass, be mindful of the dust and pieces: they can scratch the sheet! So at each sanding, I used water to clean, to avoid scratching. It worked perfectly.


Designing / 3D Printing

IMG-0805.jpeg
20211017_222124.jpg

Now, I was new to CAD. I've considered several options to design my own case: Fusion 360, Tinkercad, OnShape, Shapr3d. They all have very good unique selling points. For me, I wanted an iPad app, easy and intuitive to use, possibly taking full advantage of the iPencil (which sits next to the iPad most of the time doing nothing, admittedly).

The choice went to Shapr3d so far. I'll explore the others soon.

In this phase, I've learned quite a lot, about CAD, 3D printing, and about product design in general. Without going to the very fine details, There's a few things worth sharing here.

First, the design of the led matrix separator. You want those leds to be separated and diffused. It's a combination of design, material, and, possibly, paint. I've tried several different designs (see 4 of them in the picture), including also coating the grid to prevent light leaks. In the end, the top led holder stl file above provides excellent separation and pre-diffusion, for the plexiglas to just have to complete the job with. What works is a conic design, sliced with several perimeters (I put 10 in PrusaSlicer). Forget the infill, I put only 5% and the piece is very solid and doesn't leak any light to the neighbouring cells.

Except for the led separator, I've printed everything with 0.30 layers in fast draft. My intention was to post-process with sanding, wood filler, primer, and satin paint. I will update this tutorial with this last final step soon.

The led separator was sliced at 0.20 "QUALITY" with 10 perimeters and 5% infill. All other settings are defaults in PrusaSlicer.

I've printed everything in PLA. Only time (and a bunch of games) will tell me if that was a good choice. That led matrix does heat up!


Assembling

20211017_111531.jpg
20211017_111706.jpg
20211017_112140.jpg
20211017_111102.jpg
20211017_111238.jpg
20211017_224028.jpg
20211017_224444.jpg
20211017_225727.jpg
20211017_225738.jpg
20211017_225756.jpg

Decide what level of perfection you desire and who's the final user of this. While the design allowed for a very modular architecture, and all the internal compartments are fairly accessible for repairs / upgrades, there are no screws, so a rigid result is reached only with glueing.

That being said, you may safely decide to glue:

  • the battery holder to the arduino holder
  • the big display holder to the battery holder

For all the rest, I'd rather keep things simple to open/service, so I used a good bit of BlueTack, plus the low tolerances on my own 3D design, which in fact leaves all junctions very tight.

The battery pack fits very tightly to its holder and in my case needs no glue / screws. The arduino fits tightly enough inside its holder, apart for the right side, where a big chunk of BlueTack does the job, though it's gonna be the first point of mechanical failure. The led matrix snugs into its hole and stays there, providing good grip for the led separator (BlueTack-ed onto the led matrix), and the top led holder (which has 4 little corners of BlueTack holding the Plexiglas.

In the attached video, no parts are glued (yet!). They are all either firmly pressed into each other, or BlueTack-ed.

My reason to hold on on glueing is the post-process (sanding, filling, painting). If you're happy with the bare 3D printed case, just glue all the components.


That being said, these are the steps:

First, fit the battery pack into the battery holder. Then, route the 4 dupont connectors from the Arduino's 4-way connector through the Arduino holder and the battery holder, using the 2 matching provided rectangular holes. Note the switch of the battery pack goes on the opposite side of such hole. Before mounting the ps2 joystick shield, check if the AREF pin is shorted with a multimeter. If you don't have a multimeter, or the pin is shorted, just bend the AREF pin inside (or cut it), it's useless.

Note! The manufacturer of my shield adds a small useless piece of PCB on either side of the shield. I've noticed this only after designing and printing. Check that your shield has the extra PCB material on the top (side towards the display holder). If it's on the bottom, you'll need to either modify the 3D model, or simply remove the extra PCB with pliers and add BlueTack or any other filling material.

The holes for the joysticks are perfectly centered and, together with the hole for the USB connector, will serve as a guide to fit the Arduino+shield into the case. It should all be tight on the long sides, but tight only on the left short side (the one with the USB plug),

Fit the led matrix into the square hole, bending a little its borders (let's finally use the fact that it's flexible!) if it's too tight. This is now a good time to switch the electronics on, so you can check the orientation of the leds using the gameboy startup animation. You should see a blue horizontal line of leds going down.

Center the leds+separator with respect to the big display holder. There is just a 0.5mm clearance all around the grid. A non-centered matrix-separator pair will result in a tiny bit of leds not to be visible in one of the sides. No big deal, but it would bother me.

You're good to go!

Final Remarks

20211017_231514.jpg
IMG-0807.jpeg

Final considerations:

The arcade machine can be powered by either (or both!) usb or batteries. Batteries give much more power to the leds and all in all it should be the preferred source of power. I used 1.2v rechargeable batteries, which actually give 1.3v each, so it's a perfect 5.2v power! I haven't tried with 1.5v batteries but it should work as well.

I had a lot of fun ideating, designing, building, and assembling this, and I have involved my 4 years old daughter along each step. She loves 3D printing! I've enjoyed it so much to get the inspiration to write this tutorial.

I hope it contains the right level of details. Let me know in the comments if that's the case, or else your suggestions to improve the guide - or the machine!


Have fun!