Back in the early days of video games like Pac-Man and Donkey Kong the player only had four ways to move. Up down, left and right. It was a simple time, it was a good time.
But games like time pilot came along and suddenly 4 directions wasn't good enough. How are you supposed to get those planes coming at you from the upper right corner of the screen? How would you ever rescue the last human family in 2084 if you could only move in 4 directions?
Simple enough - an 8 way joystick is required. Well that will let you play those fancy new games and not the old classics. You see it turns out that Pac-Man doesn't like 8 directions. Sure if you point up, he goes up and if you point left he goes left, but what if you point in a diagonal direction? Well in that case he probably goes the wrong way or freezes. If you don't have the right number of directions on your stick, your game may not be playable, it sure won't be as much fun as you would like.
Genuine arcade quality sticks can be bought as 4 way or 8 way and even a few mice ones that are switchable . Most times you need to open the game up to make the switch. Sometimes on the higher end ones you don't. The chief advantage of using these sticks is that they are industrial strength. You can pretty much lift a 300 pound cabinet off the ground with those puppies. If you have a 300 pound cabinet, I would recommend that be the sort of thing you look into. For me, not so much. In my living room. I need something I can stash in a drawer when not in use.
So I made these as a proof of concept and once I decide what I am building I'll be ready. Can't decide if I am using an actual arcade circuit board (Jamma standard) or an emulator. So with a bit of tweeking - this will work with both!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: How Do the Real Ones Work?
This is a look underneath an arcade joystick. Different sticks have different ways to prevent diagonal movement. This one has a little petal like pattern. The stick just doesn't move in the diagonals. So up, left, down, right - only one switch closes. Remove that restricter plate and the joystick can move in all directions. On the diagonals it will close two switches. When the game detects that two switches are closed it moves in the diagonal direction. If the game only supports 4 directions - no telling what the game will . It may keep moving in the last good direction you pointed, it may freeze until it detects a new direction or it may work the way you wanted it to.
The most likely scenario though is that your turn will end and you will shout things like - COME ON! I WAS MOVING UP! STUPID MACHINE!
Step 2: Aquire the Parts and Get Your Tools
Some stuff you will need:
A donor controller like this, a soldering iron and a solder sucker, some kind of circuit board to mount things on, screwdriver, wires...
If you are going to use this in an emulator such as MAME that sends keystrokes to emulate a joystick you need to use an Arduino Leonardo as it looks like a keyboard to your computer.
if you are trying to connect this to an actual arcade circuit board any Arduino should do, but you will also need 4 NPN transistors per joystick.
Step 3: Carefuly Disasemble Your Parts Donor
Half a dozen screws you can see and then one more hidden under a sticker. If you had a warranty left - you don't once your screwdriver pokes a hole in the middle of that sticker
Step 4: Strip Out What You Need - and Then Some!
One you get inside, under the parts we want are 6 little solder points and 8 big ones. Heat the solder up and clean it out with the solder sucker. The part is stuck there until all points are cleaned. Even when they look good to go - they still tend to hang on.
Sometimes adding solder helps, sometimes it makes it worse. Desoldering can be a real pain!
But since the iron is hot and your already in there - Strip out the other buttons and switches - they might come in handy some day.
Step 5: What Is This Thing
It is a couple of potentiometers - volume dials on the stereo except there are two of them in one handy assembly.
You remember those three little contacts we desoldered (and the other three that ran the other way)? If you connect one of the outside pins to ground, connect the other outside pin to the +5 on your Arduino and the centre pin to an analog pin on the Arduino the Arduino can figure out where in between it that potentiometer currently sits.
On these things we just stripped out at rest both sit close to the middle and the Arduino will read it as an integer value of about 512. Move it around and play with it a bit and the Arduino reads them from anywhere between 0 and 1023. Let them go back to the resting place and they ma no longer read as 512. Maybe 490, maybe 530 and yet it looks happily in the middle. So it's not exact - but close enough for the 4 or 8 directions we want. so if your tweeking the code - be sure to leave some wiggle room.
Step 6: Mount It on the Perf Board and Solder Up Some Wires
The big pins that held the part to the pcb don't fit in well with my perf board - so I just bent them out of the way. Or drill a small hole through and solder them on to make things more secure might be a better way...
When you solder the wires on be consistent in your colours as a bunch of them tie together. On the pins that run left to right, the right pin connects to the top pin on the three that run top to bottom - I used light blue. The left pin, connects to the bottom pin - I used red. I am also hooking up two joysticks- I used the same colors on the other stick. Once the connections to the pins are complete - connect all four red wires together so you have one wire/pin to pug into the Arduino (+5 volts). Connect all 4 light blue wires together, these connect to a single ground connection on the Arduino.
The middle pins (I used dark blue) go to separate analog pins on the Arduino I think I used A0, A1, A2 and A3
Step 7: Add a Switch and for Mame Your Done! for Jamma - Almost
And now wire a simple on off switch from Ground to pin 7 on the Arduino. When the switch is on one side your thumb sticks act like a 4 way joystick, flip it the other way and you have an 8 way.
How? Good question paste the text file onto the Arduino, it works like this:
When the Arduino first boots it reads the value of the two potentiometers and saves them as a baseline. The state values get set to 0 and if a pot has moved far enough from the baseline it will add a value to the appropriate state variable.
down adds 1; up adds 2, left adds 10 and right adds 20
The state values are run through a case statement and the appropriate keystrokes are sent.
A state of 1 sends the keystroke for down (d or the down arrow depending on which joystick0
A state of 11 sends down and left ( d and s or d and left arrow)...
and so on until all 8 states are accounted for.
At least that is what it does if the switch is in the 8 way position.
If the switch is in the 4 way postion the Arduino compares which axis is further from where things were at the time it started running sends just the single keystrokes instead.
And that's how it does it for Mame.
But in case you want to use these tiny little joysticks on a real arcade circuit board you have one more step.
(The sketch on this page sends the keystrokes for mame. It also scans a couple of buttons and sends them if required. Things like start, credits, fire... Lots of info out there on how to set up Mame, today I am just covering the joysticks)
Step 8: But Since Your Wiring This to a Real Arcade Game Get Some Transistors
Do most everything as before but connect some NPN transistors as per the attached schematic.
Normally the connection goes Jamma harness -> to joystick -> to ground.
Here you go Jamma harness -> to NPN collector
The Arduino pins (2,3,4 and 5) each go to a base and Emitter goes to ground.
Ground on the Arduino goes to ground on the Jamma harness/board.
The sketch on this step doesn't send keystrokes - instead it closes the switches the way a joystick would do it. If your running a Jamma board almost any Arduino would work. If your using an emulator that uses keystrokes to simulate the arcade game buttons you need the Arduino Leonardo.
The sketch on this page sets pins high and low to drive the transistors.
Step 9: Now to Find Something to Put This In...
Doesn't look like much but there it is. Two thumbsitcks that now work just like actual arcade sticks.
Someday soon I should have the rest of the parts I need and I can do something with this amazing technology!
Participated in the
Game.Life 3 Contest