Skip to main content

Don’t reinvent the eel

Robots that don’t move around by themselves aren’t much fun.  Because you’d have to tie them to the back of a pterodactyl to fly them around.  Or attach them to the tail of a unicorn to make them hunt for pots of gold.

But don’t worry.  Humans have invented the wheel.  So let’s not reinvent it.

We’ll simply attach the wheels to Rosie’s plastic body and send instructions to the motor controller board that controls their motors using the Raspberry Pi.  Bit like how brains send signals to our legs through our nerves.

But let’s not get too scientific.  We just want to make some plastic boxes move around the floor to scare the cat - and the grandparents.  Or preferably both.  Now how hard could that be?

You will need to have these:

  • Raspberry Pi 3, and Raspbian running on SDHC card
  • A computer from which you are connecting to the Raspberry Pi remotely 
  • A robot / rover kit (which includes at a minimum: motors, motor controller board, wheels and some form of additional power supply, like a battery pack).  Exact contents will differ depending on the kit.  In this example, we have used a rover kit made by Monk Makes (  Other varieties are available.
  • A 'body' to attach your wheels to, if you are not planning to use what's included with the kit.  We used a cheap plastic storage box for Rosie's chassis, the type sold in high-street discount stores (you know the ones!). 
  • Electric drill and screw driver (and suitable screws) if you intend to go off-piste with your robot chassis

You will need to have done these things:

  1. I’ve got Pi(3) brain
  2. Why-Fi-ght the Wi-Fi?
  3. Hurrah-ndom inventions

You will need to do this:

    • Assemble the kit and prepare the chassis.  This will basically involve attaching the wheels to the motors, attaching the motors to the motor controller board, and attaching the motor controller to the Pi.  An additional battery pack will be connected to the motor controller board as well.  Amidst the excitement, don't forget to attach the motors / wheels to the chassis.
    • Download (clone) the Python files from GitHub to your Pi that will allow you to control the motors using the motor controller board supplied with the kit
    • We like to move it, move it!

    What do you get after all this?

    After our frantic foray into Raspbian OS and Python programming, we finally get Rosie to do what robots are meant to do.  Yes, we'll get to move her around using all the things we've learnt so far.  Silly robot dancing, here we come!

    But before that, time for another introduction.  Budding roboticist - meet your new friend, GPIO, which stands for General Purpose Input / Output.  It's the bank of 40 pins mysteriously sticking out from one corner of your Pi 3.  And as its name suggests, it is how we get the Pi to talk to other bits of useful hardware.  And if you want to move a robot around, what could possibly be more useful than a motor, with a wheel attached to it.  In fact, two of those please so that we can make it turn around as well.

    And in order to claim swift victory, we will simply use whatever Python Libraries (a collection of software) that was provided with the kit to make the robot glide (un)gracefully across the floor.  There's plenty of time later to personalise our Rosie.  And to understand what's actually going on behind the scenes.  But for now, we just want to see a plastic storage box powered by a Raspberry Pi move across a garage floor.

    This is simply too much detail:

    Let's begin with the chassis.

    How you get your motors (and therefore your wheels) working will be different depending on the kit you have.  So it's best to be sensible for a change, and first read the manual that came with the kit.  But there's also nothing wrong with using only the bits from the kit that look useful, and improvising the rest.  And where better to start to ignore the instructions than when it comes to the robot's looks?

    Enter the... (audience pauses with excitement) plastic box.  It's extremely cheap.  It's lightweight.  And with a few unsightly holes drilled, we can attach anything to it (like sensors, cup holders, mosquito swatters, a spatula, etc, etc).  Let's then call this our prototype, as this makes it sound more acceptable.

    Next, let's attach the motors with the wheels in whatever position that will give our robotic friend the best balance.  I'm sure we could make use of some clever maths and science to advise us here, but where's the fun in that?  Eventually, we opted for two rear wheels, and a swivelling castor wheel at the front.  There's no right or wrong answer here.  Just trial and error.  Let's pray that Rosie will glide elegantly across the dance floor like a disco queen, and not stomp across like an angry teen.

    We also drilled holes by the wheels so that wires from the motors could be pulled up through and into the box... or the compartment (as this sounds more professional).  Direct Current (DC) Motors work by converting electrical current from a power source into rotational movement using a magnetic field, and these cables help carry this current.  But current from where?  A strange new device called the Motor Controller is introduced.  Not only does it provide power to the motors from a separate AA battery pack, but it helps the Pi communicate with the motors, almost like a little translator from the sophisticated and elegant language of Pi and Python, to the primitive signals understood by the motors.  The motor controller included in our kit was a RasPiRobot v3.

    Hey, look.  We now have a plastic box full of circuit boards and cables.  And some motors and wheels.  Now let's try to move it - not with the power of our mind, but with the power of our Pi.

    We should return to the Pi, or as we have been calling it - Rosie's brain.  Can you see that this is now a wannabe remote controlled robot?  That's why we'll need our SSH connection back from this point onwards.  No other cables are allowed.

    Now, we could just sit down for the next days / weeks / months working out how to program the motor controller to control the motors.  But technologists like to build on what others have already done.  And your kit should point you in the direction of some Python software already written for your motor controller that allows you to control the wheels using simple commands.  And quite often, these are shared on a site called GitHub which happens to be the most popular code sharing site on the planet.

    For our Monk Makes' Pi Rover Kit, the instructions inform us of some Python libraries (collection of Python software) that we can download.  These will allow our Python programs to interact with the motor controller in a way that we can easily understand.  Let's navigate to our 'rosie' folder and download (clone) the libraries from GitHub.

    ...checks that we are still in the pi user's home folder (/home/pi)
    cd rosie
    ...let's continue to store all our files in the 'rosie' directory, including the files we are downloading
    ...confirm that we are now in the rosie directory
    git clone
    ...this funny looking command allows us to clone (or download to you and me) the Python libraries for our motor controller (RasPiRobot v3) to the folder that we are currently in

    Providing that your home network has an Internet connection (which it should if you are reading this!), after a few seconds, it should tell you that it has completed.

    The installation instructions tell us that we should install the downloaded libraries so let's - for once - follow the instructions.

    cd raspirobotboard3/python
    ...Navigate to the 'python' folder in the 'raspirobotboard3' directory.  Why?  Because it tells us to.
    sudo python install
    ...Run using Python to install the motor controller files.  Why?  Because (again) it tells us to.

    It looks like the installation script has completed what it was doing.  Successfully.

    Finally, the instructions tell us that there are also some example programs available on GitHub that show us how to move a rover around.  Yes please!

    cd /home/pi/rosie
    ...goes back to the directory where we are storing our files
    git clone the example programs for our motor controller

    After all this, we should be all set to go.

    What were we doing?  Oh yes - we remember - we want to move a plastic box around the garage floor.  We want to be in total control when we do it, like a rock star.  We want to tell it where to go, and it needs to listen to us.  Thankfully, there is a sample program for that.  It's called '' so let's copy it to our 'rosie' folder.

    cd raspirobot3
    ...changes directory to 'raspirobot3' folder containing all the sample Python programs
    cp ../
    ...copies the '' program up one folder above (/home/pi/rosie).  We are also renaming it to '', because we can!  We can safely edit it in the future now without affecting the original.
    cd .. 
    ...moves back up one folder to '/home/pi/rosie' 

    Now, are you ready to see a plastic box move?  Do you have your popcorn ready?  Do you have your sledgehammer beside you just in case your robot goes out of control and needs to be terminated?

    ...runs the '' Python program.

    The controls are very simple.  Use the 'up', 'down', 'left' or 'right' arrows to move the robot around.  Pressing any other key (we prefer the 'space' key) will stop the last movement.  If it all gets too much, you can exit the program by pressing 'control' and 'c' keys together (no sledgehammer required).

    Wasn't that worth all the work?  Now, have hours of fun (more like until the batteries run out) taking your cuddly plastic box on all kinds of journeys around the house.

    For now enjoy the small victory.  Feel proud of yourself that you are now a proud owner of a non-autonomous robot, which we will attempt to turn semi-autonomous.

    Even more reading:

    Raspberry Pi's official GPIO documentation can be found here:
    For this post, great deal of credit goes to Monk Makes (Simon Monk) and Teknoteacher (Alan O'Donohoe) whose excellent work we have referenced throughout:


    1. Thanks for this fun "drive my bot around" test program. I learned a new way to access the key presses.

      Comment about (
      1) there is a harmless duplicate elif keyp == LEFT: stanza
      2) for some reason the ord(keyp) == 3 did not catch cntl-c and quit. I had to kill the process.

      (Results from Rosie the Rug Warrior Pi )

      1. Hello! We can't take credit for the RasPiRobot3 Python libraries as they have been created by Monk Makes (Simon Monk) and Teknoteacher (Alan O'Donohoe) especially for the board. Next step is to control your robot using a HTTP web interface perhaps? We do this later in Web of Pies and it makes a nice change to using your keyboard.

        Your robot looks cool in the picture!


    Post a Comment


    LoRa-Wan Kenobi

    In the regurgitated words of Michael Bublé: It's a new dawn .  It's a new day .  It's a new Star Wars film .  For me .  And I'm (George Lucas, and I'm) feeling good .  Unfortunately for Canadian Mike, the Grammy that year was won by the novelty disco classic with the famous refrain: We love IoT, even in Planet Tatooine * . *Not true. Clearly, the Star Wars producers didn't sincerely mean the last Jedi the previous time around.  Return of the Jedi, released during the decade that spearheaded cultural renaissance 2.0 with the mullet and hair-metal , was less economic with the truth.  Either way, we're going to take inspiration from the impressive longevity of the money-spinning space-opera and reboot our franchise with some Jedi mind tricks.  Except this particular flick doesn't require an ever-growing cast of unrecognisable characters, unless ASCII or UTF counts.  In place of an ensemble gathering of Hollywood stars and starlets, we will b

    Battle of BLEtain

    The trolling . The doxing . An army of perplexing emojis. And endless links to the same - supposedly funny - viral video of a cat confusing a reflection from a dangling key for a golden hamster, while taking part in the mice bucket challenge. Has social media really been this immense force for good? Has it actually contributed significantly to the continued enlightenment of the human (or feline) race? In order to answer these poignant existential questions about the role of prominent platforms such as Critter, StinkedIn and Binterest, employing exceptional scientific rigour equal to that demonstrated by Theranos , we're going to set up a ground-breaking experiment using the Bluetooth Low Energy feature of MicroPython v1.12, and two ESP32 development boards with inexplicable hatred for one another.  And let them hurl quintessentially British expressions (others call them abuse) at each other like two Wiltshire residents who have had their internet access curbed by the co

    Hard grapht

    You would all be forgiven for assuming that bar , pie and queue line are favourite pastimes of the British .  Yet, in fact – yes, we did learn this back in GCSE maths – they are also mechanisms through which meaningless, mundane data of suspect origin can be given a Gok Wan -grade makeover, with the prime objective of padding out biblical 187-page PowerPoint presentations and 871-page Word reports (*other Microsoft productivity tools are available).  In other words, documents that nobody has the intention of ever reading.  But it becomes apparent over the years; this is perhaps the one skill which serves you well for a lifetime in certain careers.  In sales.  Consultancy.  Politics.  Or any other profession in which the only known entry requirement is the ability to chat loudly over a whizzy graph of dubious quality and value, preferably while frantically waving your arms around. Nevertheless, we are acutely conscious of the fact that we have spent an inordinate amount