log in | register | forums


User accounts
Register new account
Forgot password
Forum stats
List of members
Search the forums

Advanced search
Recent discussions
- AMCS free versions are live! (Gen:12)
- New RISC OS !FamTree application reviewed (News:1)
- Returning to ImpressionX (News:)
- RISC OS interview with Richard Keefe (News:2)
- South West Show is fast approaching (News:4)
- January News Round-up (News:)
- NetFetch reaches Version 5 (News:1)
- Primesolve (PP:12)
- RISC OS FR : The Raspberry Pie contest (News:23)
- BBC BASIC Reference Manual updated (News:4)
Related articles
- Wakefield 2003 - the preview
- RISC OS 2001 show
- Newsround
- Newsround
- Easier video playback on RISC OS?
- Software migrates to the Beagleboard
- RISC OS on new hardware
- RISC OS on OMAP - the future?
- Building the Dream 4 - Random city basics
- Building the Dream 3 - Random map generators, redux
Latest postings RSS Feeds
RSS 2.0 | 1.0 | 0.9
Atom 0.3
Misc RDF | CDF
Site Search
Article archives
Acorn Arcade forums: News and features: DIY Joystick

DIY Joystick

Posted by Christopher Beesle on 00:00, 30/10/2000 | , , ,
Christopher Beesley takes us through how to build an interface which will allow you to use an analogue joystick instead of your mouse, which is undoubtably invaluable for people like myself who hate it when the mouse gets stuck in the middle of a good fight...


These are the technical notes for my interface, the Analogue-Joystick-to-Mouse-Port-Converter. I'll call it "JoyMouse" for short.



  • Allows any mouse-compatible game to be played with an analogue joystick.
  • Doesn't need any special joystick driver software to do it.
  • Powered from the mouse port - batteries not included!


  • You've got to build the circuit yourself.
  • The PIC needs programming, using a suitable programmer and software.
  • Only one joystick can be used, so a second player will have to use the keyboard.
  • It's best to use a mouse port switcher (see later).


The first thing you need is a suitable joystick. Nothing complicated; just two potentiometers for the movement transducers. However, remember that the 5V supply from the mouse port will be connected across the tracks, and we don't want to draw lots of current. I've no idea how much current can be drawn from the mouse port, but I reckon 10mA should be safe. This makes the minimum track resistance 1000 ohms, or 1K. Most joystick pots are more than this, but check anyway before spending a lot of time and effort on rewiring, fitting extra buttons, etc.

The joystick will need to have, or be adapted for, four buttons. These need to have normally-open contacts. Three of them are connected through to the normal mouse buttons, and connect to 0V when pressed. The fourth button is used to allow the joystick to be moved without moving the screen pointer. This feature permits the equivalent of picking the mouse up and putting it down somewhere else on the mat, or for trimming the stick to a central position for straight-ahead or level flight or whatever.

The potentiometer wipers should cover the full length of the track, i.e. with 5V across the tracks, you should be able to measure any value between 5V and 0V on the wipers. There are some joysticks around which only operate over a small part of the track. These will have a detrimental effect on joystick resolution, range, or both. You might find that the mouse pointer moves in a series of jerks, and manual docking of a Cobra could be tricky....

I found my joystick in a junk-box at a computer show.

For the interface itself, you will need:

  • 1 X 2-terminal 4MHz ceramic resonator, e.g. Farnell 573-930
  • 1 X PIC 16C71 micro-controller I.C.
  • 2 X 82pf ceramic capacitors
  • 1 X 10uf 10V tantalum bead electrolytic capacitor
  • 1 X 0.1uf miniature ceramic capacitor
  • 1 X 470K 0.125W resistor
  • 1 X Veroboard, about 1.5 inches by 1.5 inches
  • 1 X 9-pin mini-DIN plug, or ready-made mouse cable (go for the cable if you can - those mini-DIN plugs are a swine to solder)
  • EITHER - 1 X 4-pole DIL switch,
  • OR - a set of four jumper links and four jumpers
  • 11 X pins of your choice to make it easy to connect wires to the circuit.



There should be a !Draw file called "Circuit" associated with this text file. Now is the time to look at it.

On the left-hand side is the circuit diagram. It comprises the PIC, its oscillator components, supply smoothing, the 470K resistor, four jumpers (or DIL switches) and the wiring pins.


This microcontroller I.C. does all the work. It has four analogue to digital converters on board, of which two are used. They convert joystick voltages to digital values. See "Software", below, for how they are used.

PIC Oscillator

The clock oscillator is the ceramic resonator and the two 82pf capacitors. You could use a crystal if you want, but they are more expensive. The timing would be more accurate, but this interface does not need precision down to pico-seconds.

Supply Smoothing

The tantalum bead capacitor compensates for the long leads along which the supply has to travel before powering "JoyMouse". The 0.1uf capacitor in parallel with it prevents (I hope!) any 4MHz and harmonics getting back to the computer along the supply lines. It also helps to prevent local RF signals affecting the operation of "JoyMouse". As an active Radio Amateur, this is important to me! Fitting this capacitor probably isn't necessary;
its just something I always do.

470K Resistor

This is a pull-up resistor for the stop-pointer button. Its value is not critical. Anything between 100K and 470K would do.

Jumpers or DIL Switches

These components determine the number of mouse pulses generated for each bit-change of the digital value from the A to D converters. They can be used to match the joystick movements to your preferred setting of mouse speed, which is set up in !Configure. Some experimentation may be necessary to determine the correct setting of these jumpers. They may need to be altered for different games, although I have not found this to be necessary. But then, I havn't got all the games.... 8-(

Wiring Pins

These just make it easy to connect the board to the joystick and mouse lead. You can solder wires through Veroboard holes if you like.

The mini-DIN plugs are a) difficult to get, and b) a real challenge for anyone who thinks they're good at soldering. If you find an Acorn mouse at a computer show for a sensible price, it might be worth buying it and cutting the mouse off.

Wiring points are lettered rather than numbered to avoid confusion with the PIC pin numbers. Note that letters I, O and Q are not used.

To the right of the circuit diagram is a diagram which shows how to connect the finished board to the outside world, i.e. the joystick and the mouse port. My issue 1 (June 1991) copy of the A5000 "Welcome" booklet shows, on page 78, a table of mouse port connections. In this table, pins 5 and 6 are reversed. This may have been corrected in later issues. The 5V supply is pin 6.

Which end of the joystick pot tracks you connect to 5V and 0V will depend on your choice of joystick. If you find it works backwards when you try it out, just reverse the connections.

At the bottom of the page are two pictures of the board layout I used. The right-hand picture is actually readable! The left-hand one is actual size, which shows how concise the PIC approach is. Previous designs, using ordinary logic chips, would have occupied something about the size of a shoe-box, with a power supply to match. Needless to say, I never bothered to build any of them.

Wiring points C and D are not indicated on these diagrams. They are the ones between B and E (surprise surprise), the jumper links or DIL switches. Points B to E are not actually wiring points as such, but I decided they needed some sort of reference....



There are several track cuts to be made. Use a spot-face cutter if you've got one, or a small drill if not. Clear off any swarf, and check for an infinite number of ohms with a meter if you have any doubts. Note:


  1. If using jumper links, you need to cut the tracks BETWEEN holes, the cuts shown as heavy black lines.
  2. There are 12 cuts to be made with the spot-face cutter. They are shown as thicker circles on the layouts, as follows:
    • Nine under the PIC.
    • One to the east of PIC pin 17, between terminal G and the resonator.
    • One to the east of PIC pin 14, between the two 82pf capacitors.
    • One to the east of PIC pin 16, between two wire links (see below).
  3. There are 8 wire links as follows:
    • Between PIC pins 2 and 3.
    • Between PIC pins 3 and 5, and the west side of all the jumper links.
    • Between PIC pin 4 and the positive supply rail.
    • Between PIC pin 9 and the 0V rail.
    • Between PIC pin 14 and the positive rail.
    • Between PIC pin 16 and the north end of the ceramic resonator.
    • Between the south end of both 82pf capacitors.
    • Between the south end of the left-hand 82pf capacitor and the 0V rail.
I recommend using a socket for the PIC, especially if you buy an EPROM or EEPROM version. You might want to use it for something else one day!

The ceramic resonators can be an awkward fit in the Veroboard. I had to mount mine diagonally, and juggle the 82pf capacitors to suit.



Always recommended before plugging in to your ŁK+ computer. Before doing anything else, check visually that everything is where it should be. Check especially for solder blob shorts between pins on the mini-DIN connector.

Then, ideally you need an oscilloscope; that way you can observe the quadrature pulses. A simpler method, to prevent disasters, is to power-up the interface using a bench power supply set to 5V (or 4 Ni-Cads). Check that the current drawn is fractionally above the calculated value flowing through the potentiometer tracks. Do this anyway, even if you've got an
oscilloscope. So long as there is only a tiny extra current, it's safe. If the voltages on the signal pins seem to be fixed at either 0V or 5V, it won't damage the computer. The current drawn is the main thing to check; you can sort anything else out later.

Check the buttons operate properly while you are at it. Using an ohm-meter with one side connected to 0V, they should read open-circuit when up, and short-circuit when pressed.

Setting up

With the computer switched off, plug in "JoyMouse". Set the joystick to the centre position. Switch the computer on.

When it has booted-up, you should find the mouse pointer at the centre of the screen as usual. Waggle the joystick and check that the pointer moves as expected. Hold the stop-pointer button in and waggle the joystick again. The pointer should remain stationary.

The three joystick-mounted mouse buttons should work as normal, i.e. Select, Menu and Adjust.

The jumpers (or DIL switches) can now be experimented with. Set them so that the pointer moves to the screen edges or beyond when the joystick is at its extreme positions. The switches are read at regular intervals, so there is no need to re-boot "JoyMouse" every time you change them.

And that's it! Load "Elite" and start playing if you want, but in order to get used to this new means of control, I would recommend something a bit tamer to start with. "Chocks Away" in practise mode is pretty good. Don't forget to select mouse control from the menu!



The file JYSM.ASM is the source code for my program. It is an EDIT file copied from a PC (you can tell from the all-capitals filename). It does all the essentials. There are no frills, and no attempts to optimise either speed or memory used. The source code is, er, adequately commented.

The file JYSM.HEX is the hex code for the PIC. It is probably pretty useless by itself, but I thought I'd put it in anyway....

For each axis, the A to D converter is read, and the value compared with the previous value. If it is different, the stick must have moved. Which way it moved is determined by finding out if the new value is less or greater than the previous value. The new value is then stored, and used as the old value next time around. A sequence of mouse quadrature pulses is generated which cause the screen pointer to move, or the game to be controlled. A counter is used to determine the length of the sequence, and the number of pulses generated per count is determined by the jumper links or DIL switches. When the pulse sequence is finished, the other axis is subjected to exactly the same treatment.

Various delays are included. One is to ensure that the mouse pulses are of a sensible duration. Another is to allow the A to D converter time to carry out a conversion. I guess I could have used interrupts for this, but a) I'm a great believer in KISS, b) it's not necessary for this application, so c) why complicate the issue?

There is no point in trying to make the program run faster. In fact, much of the processor time is spent in delay loops. One reason is this - I found that "Elite" does not seem to use any sort of buffer between the mouse and the movement-control software. Or if it does, the buffer is very short. So if you move the mouse (or joystick) too quickly, the software misses pulses and you don't rotate as quickly or as far as you expected. Or the mouse runs off the edge of the mat. This can be neutralised with the mouse by picking it up and putting it down on the mat somewhere else. But if you run out of joystick travel, you have a problem. The stop-pointer button can be used, but its a bit slow and something you don't need when you are surrounded by pirates....

A possible improvement could be a continuous fire facility, toggled by double-clicking the fire button. You'd have to take the fire button through the PIC instead of straight to the mouse port. I'm sure you will think of other useful facilities.

As for "Rumble Packs", well, that's a whole new ball game....


Mouse Port Switcher

I can't recommend the use of one of these highly enough. The mouse mini-DIN connectors are very delicate, and I don't like the idea of repeatedly swapping mouse and "JoyMouse". Avoid the cheap ones (if you can find one) which only switch the power, leaving the signal lines connected in parallel at all times.

I built my own, using two CMOS 4-bit multiplexers and a DPDT switch. The signals (including the buttons) are switched using the multiplexers, with one pole of the DPDT switch selecting the channels. 0V is common to everything, and is not switched. The 5V is switched using the other pole of the DPDT switch. So only fourteen of the available sixteen multiplexed channels are used (four quadrature and three buttons from each source). Don't forget to connect the unused inputs to 0V, folks!

The 9-pin mini-DIN sockets might be a bit difficult to get hold of. Buy a cheap switcher, but don't use it as it is. Just use the two sockets, and the PCB to connect to a decent switch circuit.


Other uses

Apart from playing games, the interface can be used for all sorts of things where 8-bit analogue values are sufficiently accurate. For instance, you could monitor temperature changes via the mouse port, using easy BASIC programs. In this case, it would be better to build "JoyMouse" into a box by itself, with connectors, rather than putting it in the base of a joystick.

There is potential here for helping disabled computer users. People with restricted hand movement for example might find "JoyMouse" easier to use than the conventional mouse. And it is compatible with all known programs!

Best of luck guys, and have fun!

So, there you have it folks, no more excuses for being destroyed by a pack of Caimen, when you can just hook up your joystick and blow them away. Note: All designs and text remain copyright of Christopher Beesley. Neither he, nor Acorn Arcade will accept liability for any damage caused in following these procedures, nor for lack of sleep and addiction to Elite...

Log in to comment on this article

Acorn Arcade forums: News and features: DIY Joystick