Arduino Arcade Controller

Hi I'd like to know if its possible to use an arduino board to interface to about 60 micro-switches as part of an arcade controller for MAME. Arduino seems to be the ideal solution with just one usb connection but I don't know how plausible it is.

From my limited understanding, with research I've done in the last couple days, I believe that I would have to use a multiplexer between the board and controls because of the lack of so many inputs on the board. I would think that there would be two scans (one of multiplexer and one of the micro-switches) and it may miss something.

I have looked at alternatives but many are far more expensive or are prone to ghosting. If any one has any advice I would appreciate it :slight_smile:

Thanks

You could wire the switches in a matrix, and use the Keypad library. [ maybe have a look at it's tutorial ]

This is a 4x4 example.

Just extend that to 6*10 :slight_smile:

The problem is... that while you can read switches... MAME would expect its input from a HID device. The Arduino is a USB/Serial device. You would need to do some research into the USB HID shield as well.

The project you want to include in your research is this one:

http://code.rancidbacon.com/ProjectLogArduinoUSB

You'll probably want to wire the switches up as an 8x8 matrix (with 4 "empty spots").

How you decode it depends on whether you have other jobs for the Arduino: if that's its only job, you can use up nearly all the pins for the 8 rows and 8 columns.

If you need pins for other purposes, you can use a 74HC138 to turn 3 output pins into 8 "row select" lines, and/or use a 74HC151 or 4051 multiplexer to select one of 8 columns using 3 outputs, and feed that to one input. So you could scan all 60 switches using as few as 7 digital pins.

There are examples in the Playground area for the multiplexer part. You may have to google the wider web for examples of using the HC138.

Ran

Thanks for the replies :slight_smile:

The problem with a matrix is ghosting onto other keys. Using that diagram, If I where to press SW7 and SW10, SW6 and SW11 would be read as closed too. But maybe it could be fixed in software if the keys are scanned often enough to rule out 2 simultaneous key presses? Also the fact that the joystick can only be pressed in two directions at the same time (diagonals) should probably influence the way that I set up the matrix.

Software can't solve the phantom press problem. No matter how frequently you scan, if SW7 and SW10 are held down , the moment you press SW6 or SW11 the controller will still read both as pressed.

What you need is a diode in series with each switch to block any current path that could lead to a phantom press.

Why would the joystick's mechanical limitations impact the matrix layout? It has 9 possible positions (8 directions + centered) which means you need 4 bits to represent its state. That means 4 switches each of which can be read independently, just like every other button on your controller.