Everything for Electronics

Tech Forum





November/December 2018

PC Joystick Interfacing

Is it possible to connect a joystick to a microcontroller? PIC, PICAXE, etc. I don't want to have to take apart and hack the joystick. If so, what is required?

#11181
Nick Hulst
Cedar Rapids, IA

Associated files:



Answers

Digging into the far recesses of my memory, the classic PC joystick with the DB15 connector used a resistor pot on each axis. Since ADC was expensive at the start of the ‘80s, IBM opted to use an RC based timer where the R (resistance) came from the Joystick axis and the capacitance was on the MoBo. I’ve not taken one of these apart but having looked at the dev docs it was a matter of resetting an axis, which would charge or discharge the cap and then count to yourself until the opposite state was met. I don’t remember which polarity it used.

With a pair of ADC channels at your disposal it should be way simpler and certainly quicker. You might have to wire resistors in parallel to make a voltage divider. Get your hands on one of those sticks and it should be straight forward to figure out. The buttons were simply switches tied to other pins on the connector.

Jon Foster
Bend, OR

It is possible to connect a joystick to ANY computer/processor that has analog or digital input capability!

The first question to answer is this: ANALOG (i.e., dual XY potentiometers) or DIGITAL (OPEN/CLOSE switches) joystick?

ANALOG joysticks (ala Atari 5200) use two potentiometers (typ. 10K-50K) to send varying voltages (typ. 0-5VDC) to two A/D converters — one for the X axis and one for the Y axis. The applied voltages generate two numbers and the software uses them to position an object on the screen.

DIGITAL sticks (ala Atari 2600/7800) use four ON/OFF switches: UP, DOWN, RIGHT, LEFT. The 4 switches have one COMmon connection (usually DC Ground) and the other switch side feeds a digital input looking for an ON (switch depressed — input grounded) or OFF (switch not depressed — input floating) state. The LENGTH OF TIME the switch(es) are depressed determine object movement and speed of movement (i.e., longer press = increase the speed) and the combination of two depressed switches gives you diagonal movement. The software does all the work in reading the switches and interpreting the action. The paddle controller for the 2600 was a single potentiometer with 1 (or 2?) button switches.

Action buttons (i.e., FIRE button) on the sticks are just ON/OFF switches connected to digital inputs. The majority of Joysticks typically have one action button.

Just do web searches on Atari joystick wiring to get wiring diagrams. The Atari sticks (2600, 7800 and 5200) can still be found, as well as replicas. The 2600/7800 sticks use a DE9S (9-pin female) connector and the 5200 uses a DA15S (15-pin female) connector for interfacing. Interestingly, Apple made an XY joystick for the Apple 2 that used a 14-pin DIP plug to directly connect to a special socket on the motherboard.

Trust me, it’s easier to purchase, or locate at a Goodwill, a pre-built Joystick (analog or digital) rather than try and build one yourself. The Atari type sticks use readily-available D-type mating connectors which are not difficult to wire to your project using the stick’s wiring diagrams as a guide. The great thing with them is they use no more than +5V, making them very safe interface devices.

Ken Simmons
Auburn, WA