How to make your own controller for Raspberry Pi games – from scratch
We recently demonstrated how to make a simple game of Snake on the Raspberry Pi computer. Now, we explain how to build a gamepad to control it – in plain English.
Building custom hardware is not as difficult as it may sound, but it does require some equipment and supplies not usually found in the average household. These do not have to cost a fortune and are easily available.
Read more: How to make Snake game
Raspberry Pi beginner's guide
Make a simple LED game with Raspberry Pi
The equipment needed includes a basic soldering kit (around £10), a wire-cutter tool (£5), a wire stripper (£5), some lengths of wire (£3), some button-type switches with matching resistors (£3) and some female-to-female jumper wires (£4) to connect the finished device to the Raspberry Pi.
The only additional piece of equipment required is a length of stripboard – a type of circuit board suitable for creating prototype devices by soldering components through a grid of holes. A good source is Maplin, where it is available to order using code FL17T (£6).
Start with the stripboard
We will be creating a game controller for the Raspberry Snake game from last issue. This controller will connect to the Pi’s GPIO (general-purpose input/output) port at the top-left of the Pi. This might sound complicated but it is very easy to build and an excellent way to practise soldering.
First, get a piece of stripboard and snap it to length by counting at least 15 holes from one end along the length, not the width. Place some pliers or side-cutters alongside the required break line and twist, but be careful - the snapped edges of the stripboard can be sharp. Trim them with side-cutters or file them down.
Look at the stripboard’s underside: copper strips run across the board with a break in the middle. These strips connect the holes together electrically so be sure to position components in the correct holes before soldering. Choose an end of the stripboard to be the ‘top’, ensuring the strips run side-to-side, not up-and-down.
Adding the switches
Four switches will be used to represent the snake’s four directions. Each switch has four legs, set in pairs. When inserting the switches into the stripboard, they should be turned so that the legs are sticking out from the sides, not the top.
Count five holes down from the top of the stripboard and six holes in from the right-hand side, and place the top-right leg of one of the switches into the hole. The top-left leg should be on the same row seven holes in from the left, and the bottom two legs in the same column two holes down from the top legs. If necessary, bend the legs slightly to fit.
The next two switches should go immediately beneath the first switch, with the top-right leg of the right-hand switch sitting four holes in from the right and the top-left leg of the left switch five holes from the left. There should be no holes showing between the tops of these switches and the bottom of the first switch.
The final switch goes directly beneath the last two switches, lining up with the first switch. The top-right leg should be six holes from the right-hand side of the board, and 11 holes from the top of the board. Check your work against this diagram.

Now turn the board over and solder the legs of the switches into place. Do this by pushing the hot tip of the soldering iron against both a leg of a switch and the copper track, then wait for a few seconds and push a length of solder against both. When the solder melts to cover the hole, retract the solder, then the iron.
Repeat the process for each of the legs, except the two legs which are poking through holes in the middle of the board, where there is no copper track; these legs should be left unsoldered.
Connecting the resistors
For the Pi to detect the switches, the controller needs some resistors on each switch. These will connect to the Pi in such a way as to provide power to pins on the GPIO port until the switch is pressed. Insert the resistors into the stripboard so that one end of each is pushed through holes at the very top of the board. Three resistors should be pushed into the top-left-most holes, and one into the top-right-most hole (again, check our diagram).
Article tags
Related articles
Content Recommendation
Q.Why is Windows Backup skipping files?
Q.Why do my scanned documents display gibberish?
Q.How can I convert MTS files to edit in Windows Movie...
Updating your subscription status
Nice job
Thanks Gareth. Nice job and gives some nice ideas for other projects. Is there enough GPIO pins for a 2 player (simultaneously) controller?
Posted by David, 30 Dec 2012
Two player controller
I think this should be possible as there are enough GPIO pins to cope with four more inputs http://elinux.org/RPi_Low-level_peripherals#GPIO_hardware_hacking Depending on whether you want them to be on separate boards (which rather makes sense) providing power to both might be fun. I think you might be able to use pin 17 as a second source of 3.3V power but I'd check before connecting anything
Posted by Tim Smith, 02 Jan 2013