RetroBox and illuminated buttons

While building yet another RetroBox arcade I got to work to see if I could add some awesome illuminated buttons.

Since I was really pleased with my previous build, I decided to continue to use RetroPie as a foundation and add my own modifications on top of it. For the most part I was just making minor changes such as changing the way EmulationStation handles gamelists, adding Xin-Mo controller support and customizing the overall theme. For the next build I wanted to add something special. After giving it some thought I settles on adding illuminated buttons that would toggle on/off depending on which one are in use by the emulator or rom.

Collecting the parts

Schematic for RetroPie LED circuitFor this project I bought a USB Interface & Chrome effect Joystick set similar to the one I used in my previous build but with illuminated buttons support. One of the biggest drawbacks with this set is that it only contains 14 buttons while my build needs 16, so I had to buy two additional buttons and I also got two dead bulbs I’m waiting to get replaced. According to the specs the buttons are supposed to use 12V but even with only 5V they are actually quite bright. Since the screen I’m going to use already features a 5V USB port I may use that for power instead of a 12V power supply. At least for testing purposes 5V will do just fine. If you are interested to see the difference in brightness based on voltage values, take a look at my video on YouTube.

In addition to the joystick set, I needed some electronic components in order to be able to control all lights individually. Since the Raspberry Pi only provides 3.3V and about 15mA from the GPIO ports I needed to make a simple circuit using MOSFET N-CH transistors. In order to be able to control all LED’s individually I had to use 16 transistors. For information on how I assembled the circuit take a look at the schematic. Please note that the resistors are only there for the simulation because the buttons have them builtin.

Writing the code

2015-11-14 16.34.45My main purpose for this project was to make the buttons indicate which buttons are in use for any given emulator or rom. While console emulators such for SNES and GameBoy do not have much information about button configurations on a per game basis (unless scraped from the web), MAME is a completely different story. Thanks to files such as controls.xml and nplayer.ini it’s quite easy to determine which buttons are in use and how many players a specified game supports. Using these two files and the config files residing in /opt/retropie/configs  I pretty much have all I need to get started.

I’m still writing the script but the main idea is inject two lines of code into runcommand.sh because this file is executed before and after all emulators. The other big advantage of this file is that it already has variables that contain information about the system, emulator and rom being launched. The only thing I need to do is to write a small python script that would take these variables as an argument and interpret the supporting files.

The script would need to map the GPIO pins and the physical buttons and configure the GPIO pins so we can control them. Using the system variable it should then look for a config file in /opt/retropie/configs/  and parse the button configuration if found. In case the system is set to MAME we also want to parse controls.xml and nplayer.ini for additional information before turning on the correct LED’s.

Stay tuned for updates!

Gallery

 

Share this:

5 comments, add yours.

Brent

I was incredibly impressed with the video lighting up how many buttons are needed for each game. Can I possibly convince you to give me detailed building instructions for the LED wiring and the script you used? Or perhaps more detailed instructions overall? I would be highly motivated to donate some $$ through Paypal for this….

Benjamin Krause

Benjamin Krause

Author

Hi, thanks for the interest in this project. It’s on the todo-list, but unfortunately is has been that for quite some time now. I’ll try to get to it and at share the drawings and code in the next couple of days. 🙂

Leander Vanhulle

started my own build. Made special circuit boards to power each individual button and hoping I could use your script or get a draft to start from.

Benjamin Krause

Benjamin Krause

Author

Awesome. I’ll honestly try to get it done before next week. Wife’s pregnant and I’ve got a whole lot of work recently. So that’s the two main reasons I haven’t been able to be as active on my blog or YouTube. I’m still working a lot on new cool things, just focusing on getting my own arcade finished. Before next week, I promise… 🙂

Claudio

Simply incredible, it would be possible to share how you managed to do it ?, I am setting up a bartop for my son. (Sorry, do not speak or write English T_T).

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.