Joystick-Port Interfacing: the PIA as a Parallel I/O Port
- Year
- 1983
- Type
- DIY project
- Category
- General-purpose I/O interface
- Manufacturer
- Homebrew designs (Marshall S. Dubin; John Anderson), The Creative Atari
- Tags
- joystick-port, pia, porta, portb, pactl, 7407, relay, logic-probe, creative-computing, diy, beginner
- Related
- Real-World Interface (Antic Relay Controller), 6520 PIA (Peripheral Interface Adapter), Driving an RC Servo from the Joystick Port (Antic, 1984), Joystick Ports as I/O Lines: Programming the PIA from BASIC and Assembly, AtariCom and Other Atari-to-Atari Link Cables, Build Your Own Light Pen (Penlight Pen)
Overview
The four controller jacks on an Atari 400/800 are far more than joystick sockets. They provide 16 programmable digital I/O lines (the two 8-bit ports of the 6520 PIA), 8 analog inputs (the paddle lines, converted to 0–228 by POKEY), and 4 trigger inputs. In "Interfacing Your Atari", collected in The Creative Atari (Creative Computing, 1983), Marshall S. Dubin showed how to use them to light lamps, dial phones, read thermostats and drive relays. Nearly every later joystick-port project, from speech synthesizers to EPROM burners, builds on the same basics.
XL/XE note: these machines have only two controller jacks, so you get PORTA (8 lines) only. PORTB at $D301 is used internally for memory control.
Programming the PIA
| Register | Address | Function |
|---|---|---|
| PORTA | 54016 / $D300 |
jacks 1 and 2 (jack 1 = bits 0–3, jack 2 = bits 4–7) |
| PORTB | 54017 / $D301 |
jacks 3 and 4 (400/800 only) |
| PACTL | 54018 / $D302 |
port A control (bit 2 selects data or direction register) |
| PBCTL | 54019 / $D303 |
port B control |
On power-up every line is a high input. To read, simply pull a line to ground. The OS shadows STICK0–3 at 632–635 ($278–$27B), or use BASIC's STICK(n). To make a port an output:
10 POKE 54018,56:REM PACTL = $38: select the direction register
20 POKE 54016,255:REM all 8 bits are outputs
30 POKE 54018,60:REM PACTL = $3C: back to the data register
40 POKE 54016,12:REM data: bits 2 and 3 high
Dubin's article includes a short BASIC "PIA port demo" that lets you configure any port for input or output, write values to it and read them back.
Driving real loads: the 7407 board
The port pins can't drive much. The 400/800 documentation of the time recommended no more than one TTL load. Dubin weighed three ways to boost them (transistor drivers, opto-isolators, and an interface IC) and chose the SN7407 hex open-collector buffer. It can switch up to about 30 V at small-relay currents, and one chip handles six outputs.
- Each port line feeds a 7407 input, with a 2.2 kΩ pull-up to +5 V.
- Each 7407 output is the ground side of a relay coil. The other end of the coil goes to a separate supply, not the computer's +5 V pin.
- Connect the external supply's ground to the joystick port's ground, pin 8.
- Add small decoupling capacitors, and wire pin 7 (GND) and pin 14 (+5 V) of the 7407 once for all gates.
Logic sense: writing 0 turns a device on, and 1 turns it off. Dubin preferred this over the inverting 7406 because the PIA powers up with every bit high: with a 7407 nothing switches on until your program says so, while with a 7406 everything would come on at power-up. LEDs or 5 V pilot lamps can replace the relays for testing.
A logic probe for under a dollar
The article also gives a two-transistor logic probe built on a 1" × 2" perfboard, which can be slid into a cigar tube with a probe tip at the front and clip leads at the back. The LED lights for logic 1. It can't distinguish a real 0 from a floating line, but "what do you want for less than a buck?"
Safety rules (Dubin's list)
- Keep mains voltages well away from the work area. Low-voltage supplies still have 110 V primaries.
- Keep wiring neat; loose wires cause shorts.
- Never wire or solder with the power on.
- Use a low-heat (25 W) iron, never a soldering gun.
More joystick-port tricks
In the same book, John Anderson's "Joytricks" shows quick, cheap modifications: rewiring an Atari joystick for left-handers by moving the fire button to the upper right, and a homemade push-button controller-jack peripheral for under $8. For more ambitious projects built on these principles, see the Real-World Interface, the Stepper Motor Robot-Controller and the SP0256 speech synthesizer.
Credits
- Picture: The 800XL's two controller jacks: PORTA's eight I/O lines. — Multicherry, Wikimedia Commons (CC BY-SA 4.0)
- Marshall S. Dubin — Interfacing Your Atari (The Creative Atari) — Marshall S. Dubin; AtariArchives.org
- John Anderson — Joytricks (The Creative Atari) — Figure 2 of John Anderson's 'Joytricks', The Creative Atari (Creative Computing Press, 1983), from a scan of the book
- comp.sys.atari.8bit FAQ, section 6.12 (PORTB used for memory control on XL/XE) (Michael Current, Feb 2026) — Michael Current (comp.sys.atari.8bit FAQ), 2026
