I am relatively new to electrical engineering so don't expect me to know much...

I want to start a kind of proof-of-concept projcet.
It should - when it is finished - run on a Raspberry Pi Zero (W).
For now, I have a RasPi 4B to test things on.

The project I want to make is a kind of multiplayer game where every player has two joysticks.
The game needs four or five players to be played.
Consequently I need to have eight or ten joysticks attached to the raspberry pi, which would result in way too many gpio ports that have to be used.

I looked up the web for some things that could allow me to do that but I couldn't find anything.

Also, the joysticks should respond relatively quickly because it is a game where you have to have precision.

I am not sure which joysticks I want to use exactly, I would highly appreciate if you could recommend me some.

  • Shopping requests are actually off-topic for this forum hence my close vote but I'll add a few ideas as an answer for you without naming products :-)
    – user115418
    Dec 17 '20 at 16:29
  • if you use switch based joysticks, then you can wire them in a matrix ... you could even use a scrap USB keyboard ... each player would get 8 keys
    – jsotola
    Dec 17 '20 at 18:29

First thing to note is that some 'joysticks' come with I2C interfaces (the Nintendo nunchucks being the classic ones) and this bus can be used by using more than one I2C device at once. Using these joysticks can save a lot of hassle BUT you may need eBay to get them.

For analogue joysticks, the simplest way is to look into I2C or SPI analogue to digital converters (ADCs) that handle multiple inputs.

Each pot on the joystick then feeds one input and you poll the ADC to find the value and then position of the joystick. Despite the joystick being able to move in four directions you only need two channels per stick.

In these type of converters you normally have a pay off and have to work out if resolution (i.e. the number of bits) is more vital than conversion speed:

  • Do you need to know the player is moving up / left - if so fast conversion speed and low accuracy is what you need
  • Do you need to know the player is 10% up and 45% left - if so conversion accuracy is more important than speed

You will find that a trade is required between speed, accuracy and cost :-)

AB Electronics have quick guide to this type of connection here but many other suppliers can be found with a quick Google search.

For digital joysticks (i.e. where each direction is a switch) there are two classic ways you can approach this:

  • Multiplex - here the switches are scanned in turn on a row / column matrix. This is how many many keyboards work.
  • Input / Output expanders (often connected to I2C). These give many many more ports at the cost of a little coding - you selected the device, the port and then read the value.

Other thoughts are a bit slow today but to get you thinking:

  1. Put a small micro-controller between the joystick and the Pi - the micro controller then does the hardworking and sits on I2C reporting a bit mapped value (for digital) or a set of values in registers (for analogue)
  2. Use Bluetooth controllers - be aware Bluetooth programming is a real PAIN in the **** due to lack of documentation unless you find a library
  3. Use a microcontroller to represent a keyboard key press for each switch and feed this is to your program

To progress this I would:

  1. Decide if you need accuracy (analogue) or general direction?
  2. Decide on the number / type of inputs (remembering buttons / tilt etc)
  3. Try a few solutions (code / hardware) on one joystick and work out if it can scale.
  4. Repeat from step one till you have a glance between cost / effectiveness for your game

Good luck.

  • Hey! So I just found out that I can connect as many I2P devices to the two pins as I want because every device has a unique I2P address, so I think I will just convert the analog outputs of the joysticks to digital (I2P). Thanks for your help!
    – RD4
    Dec 18 '20 at 8:00
  • I just saw that its name is "I2C" and not "I2P"... Sorry if I confused you.
    – RD4
    Dec 18 '20 at 8:27

The excellent answer by @Andyroo gives a lot of good information, but I wanted to mention one more variant on analog joystick interfacing.

As described, for these types of joysticks, each axis has a variable resistor and the resistance varies with the position. While one can certainly use an analog input and measure the voltage as suggested, another way to do it is to use a digital input.

With the addition of a capacitor, we can use knowledge of the RC time constant to get a joystick position. The Commodore 64 did it this way. Sketching this out, it looks like this:


simulate this circuit – Schematic created using CircuitLab

Initially, the GPIO is set to be an output and set "low" (0V) to discharge the capacitor. Note that the discharge current is all going through the GPIO pin, so a more conservative design would do some current limiting, but this was simple and cheap. Then the GPIO is set to be an input and we measure the time it takes for the resistor to charge up to a value that the input considers "high". That time can then be related to the position of the variable resistor and thus the position of the joystick.


Just get 4 USB joysticks / gamepads and a USB hub. This can be easily extended to way more devices, but bear in mind that USB is polling based so it becomes slower with each extra device you attach. Still, 16 devices with 5 hubs should be no problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.