ArcadeHID - Multi HID Interface for Arcade Projects
Introduction
If you are an arcade enthusiast you surely know how important is to have the right peripheral for the right game.
Genuine arcade controls (peripherals) are not plug-and-play, and special interfaces are needed to convert user inputs into something Pc's can recognize and handle. There are a lot of commercial products to choose from, and sometimes it could be difficult to make the right choice.
In the following I will show you how easy it is to interface most common Arcade peripherals to Arduino, expecially with the use of this simple shield: ArcadeHID.
Let's do that!
ArcadeHID - What Is It?
If you are facing a new Arcade project, the first question to answer is: which interface board should I use?
There are literally dozens of commercial interfaces out there, an this makes difficult to orient yourself in the selection of the right one. Wouldn't it be nice to have a single interface capable of handling most arcade peripheral? :)
Well, this interface is out there since 2012 and is called Arduino Leonardo.
What makes Arduino Leonardo the right choice for arcade projects is:
- It's equipped with both digital and analog inputs
- It can natively emulate all human interface devices (HID) software emulators asks for to play: keyboard, mouse and joypads (no more need for joypad-keyboard-mouse hacks!)
- There are tons of libraries and examples to help you writing your code. You don't need to be a coder to write an Arduino sketch for Arcade use!
Ok, nice, but you didn't answer to the main question: what is ArcadeHID?
ArcadeHID is a very simple Arduino shield for arduino pro-micro (sort of small footprint Leonardo) but also a collection of simple code pieces that in my intentions will help simplify the realization of any DIY arcade project, also by helping to break down the psychological barrier most Arcaders have when face-to-face with the "mistique of coding".
Joysticks and Buttons
Joysticks and buttons are the most common arcade peripherals.
They consist of simple non latching switches: when the button (or the joystick direction) is pressed, the switch is closed; when released the switch is open.
Connecting switches to any ArcadeHID D# or AD# pin will let the board see the state of the switch and, with the appropriate sketch uploaded, emulate a keyboard (or gamepad) keypress accordingly.
In the attached picture you can see how to wire a classic arcade button. Notice that only two of the three button pins are connected: COM to ground (GND) and NO (Normally Open) to D10.
The simple sketch "ArcadeHID - buttons.ino" at THIS link (Github) will emulate an "a" keyboard key press every time a switch/button connected to pin D10 is closed. It will also emulate a "b" keyboard key press every time a switch connected to pin D14 is closed. The "Buttons" function is written in the more readable (verbose) way I could think of and you can easily modify it to add up to 15 buttons (total).
To avoid "false state change detections" (any actual switch "bounces" when pressed) there's also a simple but effective debounce routine.
Arcade Steering Wheels and Analog Pedals
Racing cabinets where common when arcades where in auge. There are two main types of arcade wheels: optical wheels (also known as "360°"), and potentiometer wheels (also known as "270°"). In this step we are referring to analog, potentiometer wheels (optical wheels will be discussed in the next step).
Despite their dimensions, 270° wheels are made up of a simple, single potentiometer. The potentiometer is wired in a so called "voltage divider" configuration, with two pins connected to ground or logical +5V, the third pin (generally the central pin, called "wiper") returning a voltage from 0 to +5V as a function of the rotating position.
The exact same potentiometer technology defining the rotating position of the wheel was often used for pedals in arcade games asking for more control over the pedal position.
Be it a steering wheel or an analog pedal, in our emulators environment, ArcadeHID gets the variable voltage at one of it's analog pins (DA#) from the potentiometer wiper and translate it as an analog stick (gamepad stick) movement. In the attached picture, analog pin DA0 is used as input pin.
Being that ArcadeHID has 4 analog pins wired (DA0, DA1, DA2 and DA3), you can connect up to 4 analog devices.
In order to emulate a joypad we are in the need for the joystick library, a brilliant piece of software Matt Heironimus wrote and still maintain for the arduino community.
In the example "ArcadeHID-potentiometer.ino" at THIS link (Github) a potentiometer wiper pin is connected to ArcadeHID's pin DA0 and it's positions translated into analog stick movements on the X-axis.
Spinners, Trackballs and 360° Wheels
In a nutshell, both spinners, trackballs and optical wheels are rotary optical encoders. An optical encoder is an electromechanical device that uses a light source (emitter), photosensitive detectors, and an optical grating to convert rotary or linear position to an electrical signal. One emitter-detector couple determines the speed of the grating, the other the direction of movement.
We are not going to see in deep how an optical encoder work because so much has already been written and some "google-fu" will suffice if you are curious (and you should to better understand the function I will write down here).
For what concerns this Instructable, the only important thing to note is that, despite they look very very different, spinners, optical wheels and trackballs are the same thing "under the skin", the only difference being the number of optical encoders used: spinners and wheels have one optical encoder (one axis of movement), trackballs have two encoders (two axis of movement).
To have those peripheral working with our PC, one approach is to have their movement translated in mouse movement. This is a simple task for arduino. In the example "ArcadeHID-optical.ino" at THIS LINK (Github) the two emitter-deterctors of a spinner are connected to ArcadeHID's pins D2 and D4.
Please, notice that pins D1, D2, D3 and D7 are "special" digital pins being that they support interrupts routines. This means that every time a state change is detected (a change from LOW to HIGH in my example), the function associated with the pin is run, and every other function put on hold until the interrupt routine has ended. This is useful for those applications where timing is important. This means that you can handle up to 4 optical axes (i.e. 4 spinners, 2 trackballs or 2 spinners and a trackball...) with single interrupt routines like the one I have posted in the link above.
The function uses only one interrupt pin, but it is possible to change it to have both emitter-detector couples "interrupting" the main code when a state change is detected. I have toyed with this and, for me, there's no need for two. This is not carved in stone, anyway, and you could change it in every moment. This is the great advantage an open firmware device gives us!
Please notice that different optical devices could have different pinout with respect to the one I posted.
Aknowledgments
The ArcadeHID printed circuit board (PCB) pictured in this instructables was sponsored by those nice girls and guys at PCBWay - PCB Prototype The Easy Way. Their customers service is excellent and PCB's of the best quality.
Thanks!
ArcadeHID - Multi HID Interface for Arcade Projects
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(2)
- Dennis Watterston Dec 19,2023
- MASATOSHI OMURA Dec 25,2022
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Marco Guidolin
- Arduino Voltage Controlled Wavetable Oscillator Lurking for a simple digital filter for my modular synthesizer, I got aware of the existence of a li...
- Kurzweil K1000 K1200 Display Replacement PCB IntroductionThe Kurzweil K1000 is a classic synthesizer series that was produced from 1988 to 1992. ...
- Variable Waveshape Low Frequency Oscillator One of those modules you should want in your arsenal when starting a "DIY modular adventure" is the ...
- Discrete Voltage Controlled Amplifier Together with the Power Supply Unit, Voltage Controlled Resonant Filter and ADSR, another modular's ...
- Arduino ADSR Digital Envelope Generator It's incredible how many things you can accomplish with (as per today standards) tiny processors lik...
- Voltage Controlled Multimode Resonant Filter After getting my hands dirty with a linear Power Supply for my modular, it was time to develop a PCB...
- BA8 - Power Bus Bar While designing the Linear Power Supply PCB, I forced myself to keep dimensions within the 10 cm x10...
- ALR350 - DIY Linear Regulated Eurorack Power Supply Modular synthesizers are extremely attractive objects. With the right selection of modules, they giv...
- ArcadeHID - Multi HID Interface for Arcade Projects IntroductionIf you are an arcade enthusiast you surely know how important is to have the right perip...
- Korg PME40X External Selector "Clone" DIY Korg PME40X External Selector "Clone"I am a PME40X user, and I like this multi effect very much....
- CompuLab - a DEC H500 Inspired Logic Trainer CompuLab is a simple logic trainer I designed as a labour of love for one of those "ancient" pieces ...
- Arcade Jamma Prototypes Development Board Contrary to what one would expect, the Arcade world is not dead but growing thanks to thinkerers com...
-
Build a Walking Robot: Theo Jansen Style 3D Printed Octopod
152 0 4 -
-
-
kmMiniSchield MIDI I/O - IN/OUT/THROUGH MIDI extension for kmMidiMini
142 0 0 -
DIY Laser Power Meter with Arduino
221 0 3 -
-
-
Box & Bolt, 3D Printed Cardboard Crafting Tools
190 0 2