Simple clear advice in plain English

Make a games controller for the Raspberry Pi

How to make your own controller for Raspberry Pi games – from scratch

Build a game controller
It may seem complicated, but this games controller is easy to build

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.

Raspberry Pi controller

 

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).

Reader Comments

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

   

Add your comment

Please keep comments constructive and free from abuse of any kind and swearing. If you wish to link to a product or service online, please do so in such a way that makes it clear that it is not spam. If you are connected to any such product you should make that clear.

We may use your comments in the magazine. We may edit your comments for clarity or to remove unacceptable material. We will attribute your comments but not share your email address.

We request your email address and record your Internet Address (IP address) in order to block spam from our site. We will never share this information without your permission.

All comments are reviewed by the Computeractive Team before being published. Please bear with the slight delay this causes, you don't need to post more than once.

Click here to read our Privacy Policy

Click here to read our site Terms & Conditions

Related articles

raspberry-pi-switch-and-led-game

Making a simple game with my Raspberry Pi

Finding fun projects to do with my Raspberry Pi, a breadboard, some LEDs and switches

Raspbian wheezy

Download an operating system for Raspberry Pi

Manufacturers recommend using Raspbian, which can be downloaded from the Raspberry Pi homepage

Raspberry Pi's OS is similar to Windows

Raspberry Pi: exploring Raspbian

Use programming languages Python and Scratch, and find pre-installed applications including a web browser called Midori

Content Recommendation

Related articles

No matching document

Question & Answer

Q.Why is Windows Backup skipping files?

> Read the answer

Q.Why do my scanned documents display gibberish?

> Read the answer

Q.How can I convert MTS files to edit in Windows Movie...

> Read the answer

Best deals on the web

img

Samsung NP350E7C-A04UK

£349.99- Buy it now

img

Toshiba Satellite C850D-11Q (PSCC2E-00R00JEN)

£279.97- Buy it now

img

Lenovo G580 (MAANJUK)

£379.99- Buy it now

Updating your subscription status Loading

Most popular articles

No matching document

Poll

Do you have Windows 8?

Jargon Buster

Computing terms explained in plain English

CPU

Central Processing Unit. Another term for a computer processor.

Great shopping deals from Computeractive

Information currently unavailable