Remote Raspberry Pi Robot (PS3 Controller) - Fablab NerveCentre

Introduction: Remote Raspberry Pi Robot (PS3 Controller) - Fablab NerveCentre

These instructions try to assume very little. Hopefully, if you can boot a Raspberry Pi and have an internet connection you should be able to complete this great little project.

Basically, this is a project which will result in some specific areas which can be used in other projects.

The main outcomes will be:

Using a PS3 controller

Controlling DC motors

But along the way, you'll get a chance to look at some code and perform some often used linux commands in the terminal.

Step 1: What You Need

It's a bit of a list - but nothing is terribly expensive. I've also tried to keep the list to commonly used components that will be useful on any related project.

For example, this project could be adapted to control a garage door or to trigger some other project by incorporating a motion detector and/or camera.

So here's the list:

  • Raspberry Pi & SD Card with Raspbian installed
  • DC Motors (pictured are 2 different types - one set is geared)
  • L293D motor driver pcb (ChrisMason has described how to breadboard this chip if you don't want to buy the pcb)
  • Powered USB hub
  • 9V battery & holder
  • 5V power source
  • PS3 Controller
  • All the necessary cables/power supplies for the above
  • You'll also need to download the *.sh files (attached) to your /home/pi directory.

Step 2: Wiring the Motors

When I began doing bits and pieces with Arduino and Raspberry Pi, I didn't get why motors couldn't be connected directly to them. Here's the quick explanation.....

If you look at the specifications of a motor you'll get information about it's RPM, ampage, ratio etc. Also included will be a voltage span within which it can operate. For the majority of motors used by hobbyists and makers, this voltage span is likely to be 6V or greater.

For the motors I'm using in this project, I'll be using a 9V battery. Now, a 9V battery is too much to run the Raspberry Pi from. Also, hooking up the motors directly to the RPi means that the greedy little things will try to draw more current than the RPi (or indeed an Arduino) can provide.

This can result in damaging your hardware.

You can wire the motors, battery holder and wires to the L293D pcb as shown. The 9V battery will independently power the motors. The motors themselves are attached to terminals marked "MA" and "MB" on the board I have.

The other 3 pins (per side) are inputs 1 & 2 and an enabling terminal also. The enabling terminal could be regarded as a kind of handbrake, you have to enable the motor on the channel in order to drive it. The other 2 pins are switch controls which determine the direction the motor will spin.

Step 3: Connecting the Motor Driver Pcb to the RPi

Apparently you shouldn't connect anything to the GPIO pins while the RPi is running so it's worth making sure to heed this advice or it could be expensive.

You can connect the wiring to the RPi as shown in the image.

Don't put the 9V battery in just yet. I've found that if the battery is left in, it will slowly drain. Given that setting up the RPi for this could take some time, we'll just leave it out until we're ready for testing.

Another solution to this is that you can add a simple switch to the battery holder.

Step 4: Getting the PS3 Controller Running on the Raspberry Pi

We now have the connections all made and so can move on to setting up the PS3 controller.

There are a good few tutorials on how to do this. The one I initially used is available here:

For anyone who is a beginner at using the command line in linux going through all the commands and encountering some problems can be really frustrating. To help with that, I've started off with a completely clean install of Raspbian so that I can hopefully identify every issue you might encounter.

The first thing you need to do is install some background programs and libraries. These are known as "dependencies".

I'm going to give you something of an easy option here by providing script files for you to run. This should make the process easier. To run a scriptfile you just type "sudo sh ./" at the command prompt.

The first to be run is (Get yourself a cup of tea)

After running this script we need to check if the RPi is seeing the bluetooth dongle. Run "hciconfig" at the command prompt. This will give an output the same as the image above if you're bluetooth dongle has been attached before booting up. (If not seen, you may need to reboot)

The next script to run is This script will create a directory and download some necessary files to it. This shouldn't take long.

The third script to run is This will compile and install the sixaxis manager software. You will be prompted to answer a few questions. To do so, type nothing and just hit [ENTER] each time you are asked anything.

The next script is I'm sure you can guess what this is for - just a bit of housekeeping to keep things clean.

Step 5: Connecting to Your PS3 Controller

At this point you've done the majority of the work to having your PS3 remote controlled robot up and running. Now, we're going to make sure you can connect up to the PS3 controller and that your Raspberry Pi is receiving inputs from it.

Make sure your PS3 controller is connected to a USB port on your RPi (or to your powered USB hub).

You can now run the script which will pair your controller and then ask you to press the PS button. Unplug the controller and press the PS button - you should then see the message as per the image.

Achievement unlocked!

Your PS3 controller is now paired and ready to use with any game or robot which can take its signals.

Possible issues:

  • When running you may not manage to connect due to the bluetooth dongle possibly "sleeping". The immensely technical solution to this is to remove it and then plug it back in!
  • Everything should run correctly - if not, please comment and I can try to troubleshoot. (& update this instructable)
  • One likely issue you will meet at some point is that the PS3 controller may not be seen while plugged in to USB. Type "ls /dev/input". This will list attached input devices and should include "js0". If not, plug out and plug back in your PS3 controller USB connection and wait before listing input devices again to look for js0.

Step 6: Controlling the DC Motors With the PS3 Controller

At this point you now have the hardware connections to the motors complete and can read from the PS3 controller.

Now you can download the attached code which is written in Python.

I'd recommend placing this code in a folder - call it "PS3_robot" or something. It's just easier and safer to do this as things can easily get lost or deleted when left sitting in /home/pi.

Assuming you have only just turned on your RPi (or perhaps have moved your SD card to another Pi)you will need to open 2 terminals. In the first terminal, run:

  • sh ~/PS3control/

In the second terminal, run:

  • sudo python ~/PS3_robot/

Now you can have a go at moving the motors using the PS3 controller. Each joystick will control forward and reverse movement (see video).

Step 7: Creating a Chassis

For motor mounts I 3d modeled a few parts - here's the one's I used for this project on thingiverse.

See the attached pdf file for the chassis and the images for some of the assembly.

You'll need a decent mess of 3mm nuts & bolts to put this together.

To assemble the pi covering spacers, a circular one goes at each corner followed by the L-Shaped spacer.

With respect to the different spacers included, some have quadrants cut from them - these 5 go above the L-shaped layer on the corner of the Ethernet connection.

The few which have flats on them are for going directly above the L-shaped layer at the power socket. The remaining circular spacers make up the rest of the height to get to the top cover.

Once assembled....

Step 8: ......Enjoy!

And if you want to know a bit more about the scripts you have run and/or the python code you can do so by typing "nano ~/<directoryname>/<filename>".

The *.sh script files can be a reference point for you if you wish to try to "automate" any work which would otherwise be far more tedious.

The Python script can also be useful in other areas. For example - any work with the GPIO should be shut down afterwards as it is here.

Be the First to Share


    • Microcontroller Contest

      Microcontroller Contest
    • Remote Control Contest

      Remote Control Contest
    • Fiber Arts Challenge

      Fiber Arts Challenge



    2 months ago

    My pi for some reason isnt finding the parts of the packages like sites and such.


    5 years ago

    Can you use a different kind of controller like an xbox 360 or xbox 1


    Reply 1 year ago

    I know this is a late response, but other controllers worked, I was able to use it with an xbox 1 controller, but my best expiriences with bluetooth controllers work with my nintendo switch controller.


    5 years ago

    Do you need the Wifi dongle for anything other than installing the software? or is it necessary. Thanks


    6 years ago

    Awesome! Just what I needed. Thanx!

    Got it into a directory in home/pi.

    Couldn't get it to work at first, but after:

    sudo update-rc.d sixad defaults (from and reboot it worked.

    Was able to control a servo motor with it.

    Just need to work out how to re-connect after controller goes to sleep without rebooting...


    6 years ago

    I have the same problem as Michael and i cant seem to get it right
    Im new to this stuff so please bear with me, Im sure the second script doesnt create a new directory and the scripts, once downloaded lose their names
    Any help would be much appreciated


    7 years ago on Introduction

    I was succesful in running scripts 1-3, but when i tell it to run the tidyup script the pi says "mv: cannot stat '' : No such file or directory"

    which is weird, and so i try to skip that one and go on to the next file, telling it to run the PS3_connect_controller file, and then it says "sudo: ./sixpair: command not found"


    this is exactly what my screen says:

    pi@raspberrypi ~ $ sudo sh ./
    mv: cannot stat '' : No such file or directory
    pi@raspberrypi ~ $ sudo sh ./
    sudo: ./sixpair: command not found
    pi@raspberrypi ~ $


    Reply 7 years ago on Introduction

    I opened up the 4th file and typed the stuff in manually since it wasnt very much and this time it says that it cant move the file to ~/PS3control/ because that file doesnt exist


    Reply 7 years ago on Introduction

    Hi Michael,

    It's important that you download all files that have been included in Step #1.

    It looks like you have downloaded files 1, 2, 3 & 4 but not the file. If it's not downloaded, it can't move it.

    I hope you get this going - it's not the easiest RPi project to start with!


    Reply 7 years ago on Introduction

    I made sure that I had the file in the but it still thinks that I dont have it whenever I try to run the tidyup script.

    I have one goal with this project and that is to get my controller connected to my raspberry pi, but no other tutorials have succeeded so far, possibly because I have a fake brand controller... any ideas?


    Reply 7 years ago on Introduction

    Hi Michael,

    If you've downloaded the file then you definitely have it.

    But here's what I'm thinking; I may not have made the instructions pefectly clear and I suspect we can sort this out! So let's step through the bits in the script files.....

    1-dependencies just updates & installs some bits your Rpi will need.

    2-downloads creates a directory called "PS3control" then downloads other bits that are needed for the project to that directory. puts all that downloaded code together & installs it. needs to be downloaded before doing the tidyup - I think you've downloaded it already but perhaps not to where the tidyup script expects it to be.

    I'll assume that you can't currently find it. Here's a few commands that might help - open a terminal to run them....


    find ~/ -type f -name ""

    - you should get an output that tells you where the file is. If you don't, then you haven't got the file on your system.

    So, let's say you get a response which tells you that the file is somewhere you didn't expect. somewhere like:


    Well, the tidy up script thinks that this file is in /home/pi. The tidyup tries to move it from home/pi into a directory to keep it for use with the project. It is trying to place it into the /home/pi/PS3control/ which was created by one of the previous scripts.

    If you've run already and this is the only thing outstanding then you can use the move command to place it in the correct directory:

    mv /home/pi/project/PS3/madeupdirectory/ /home/pi/PS3control - as mentioned, this moves the to the home/pi/PS3control/ directory. It also deletes all the other stuff downloaded so that you don't end up cluttering up your pi.

    If you end up having frustrations with controllers, make sure you try it with a genuine one before writing off the code - some aftermarket ones just won't work....

    I hope this works for you Michael, let me know!