The pin-out of the joystick port is the following:
DB-15S (female)
8 7 6 5 4 3 2 1
__________________________
\ o o o o o o o o /
\ o o o o o o o /
\____________________/
15 14 13 12 11 10 9
DB-15S pin-out
--------------------------------
(o) pin 1 +5 Volts
(i) pin 2 Button 1 joystick A
(i) pin 3 Position X joystick A
(-) pin 4 Ground
(-) pin 5 Ground
(i) pin 6 Position Y joystick A
(i) pin 7 Button 2 joystick A
(o) pin 8 +5 Volts
(o) pin 9 +5 Volts
(i) pin 10 Button 1 joystick B
(i) pin 11 Position X joystick B
(-) pin 12 Ground
(i) pin 13 Position Y joystick B
(i) pin 14 Button 2 joystick B
(o) pin 15 +5 Volts
(o) = pin is for output
(i) = pin is for input
(-) = pin is common reference
Note: the above pin-out is the theoretical specification, however I
have found that pins 9 to 15 (those of joystick B) are not connected in the
joystick ports that I have seen.
Warning: I know the hard way that the +5 Volts pins cannot support high
currents. Be careful when using this source as a power supply.
Using the port
The joystick port is monitored reading from the port address 0201h.
The meaning of its bits is the following, where bit 0 is the least
significant bit and bit 7 is the most significant bit.
- Bit 0: Position X joystick A.
- Bit 1: Position Y joystick A.
- Bit 2: Position X joystick B.
- Bit 3: Position Y joystick B.
- Bit 4: Button 1 joystick A.
- Bit 5: Button 2 joystick A.
- Bit 6: Button 1 joystick B.
- Bit 7: Button 2 joystick B.
Note: the above assignment is the theoretical specification, however I
have found that those bits of joystick B are always set to 1 in the
joystick ports that I have seen.
Using the commands and routines which every programming language has to
read from the ports, you can check the status of the lines of the joystick
port. This will let you interface with your own devices, for example you
can check if a cable has been cut (alarm) or a switch has been activated,
etc. For instance, if you want to monitor the status of the Button 1 of
the joystick A and print a message when it is activated, you can do it with
a BASIC program like the following:
10 WHILE 1 : REM *** Endless loop ***
20 B1A = INP (&h0201) AND &h10 : REM *** Read port and mask bit for
Button 1 of joystick A ***
30 IF (B1A = 0) THEN GOTO 50 : REM *** Check if Button 1 of joystick A
is low ***
40 WEND
50 PRINT "Button 1 of joystick A activated."
60 END
E-mail: padilla at
domain "gae ucm es" (my PGP/GPG public key)
First version: 24-Jun-1997, last update: 28-Aug-2002
This link: http://www.gae.ucm.es/~padilla/extrawork/joystick.html
Go to the parent page: Specifications of useful PC
ports.