Building Mr Nancy the Raspberry Pider robot

Before I start, I should explain that I am very, very much a beginner. I have only a little knowledge of robotics, coding or electronics. However since doing the (very, very excellent) free Picademy course run by the Raspberry Pi Foundation, I have gained the confidence to introduce the Special Needs students I teach to more and more physical computing, coding and electronics projects.

So what you are about to read is how to build a robot spider from a beginners perspective. It is, I feel, a great little project for a beginner or child but my instructions are by no means definitive. I am sure that more experienced makers will be able to give better tips and pointers. If you are one of these people then do please comment. Also, anyone is free to ask questions :)

Can I thank all of the people in the wonderful Raspberry Pi community on twitter and on the forums, who have been very patient giving me advice about the coding part of this project.

So I was shopping in Tiger and for £5 I saw this Build your own DIY spider toy. On a whim I bought it, thinking, ‘Mmmm possible future robot project. Will give me some practice ready for work’.

And a couple of weeks later, I used it to build a robot spider that follows lines (sort of), avoids obstacles (sort of) and can be operated by remote control (really). Below I will post the build photos I took so that I could remember how I did it if I wanted to do it again.

A couple of weeks after buying the kit, I went to the Raspberry Pi 5th Birthday Party in Cambridge. Whilst there I bought the latest version of the Pi the Zero W.

When I got the Zero W home I realised that the perfect use for it would be as the basis for a robot project, so out came the spider kit I had previously bought.

When I studied the picture and the instructions I quickly realised that the kit would make a simple toy that walked in one direction. I would be able to use the Raspberry Pi to remotely make it walk forwards and maybe backwards, but nothing else :)

I realised though that if I bought a second kit, chopped the legs off one side and added it to this kit with the legs chopped off the other side then I would have two independently controllable sides to a spider. This would allow manoeuvrability, line following, obstacle avoidance, etc.

So I bought another £5 kit.

To these two kits I added:

  • Zero W (£10)
  • CamJam Edukit #3 (£18 from PiHut but I didn’t use the motors or wheels from it)
  • Powerpack (£1 from Poundland)
  • Male Hammer Header (£2 from Pimoroni or £6 including jig and female)
  • Googly eyes
  • Lolly sticks
  • AA batteries

Below are the photos of the build. They are largely self-explanatory though here and there I have added notes (particularly when things went wrong).

I started with a Zero W (and a cup of tea of course)

I am not good at soldering.

Really not good.

The Zero W comes without a GPIO header (the pins used to control robots) so you have to solder one on. Fortunately, the wonderful Pimoroni chaps have recently introduced a product which dispenses with hours of swearing at a soldering iron. They sell ‘Hammer Headers’ which just require some gentle hammer action:

With the GPIO header in place on the Raspberry Pi Zero W it was time to move onto building the kits:

At this point, I should have sprayed WD 40 onto the gears and into the gearboxes as I built them but I didn’t. Instead, I had to try spraying it in at a later point which was rather messy.

Each kit comes with two sets of four legs making eight per kit or sixteen altogther.

Each kit has one motor which is designed to drive two sets of legs simultaneously. You need each motor to drive just one set of legs (four) so need to hacksaw off the spare drive shafts:

With the basic chassis built it is time to introduce the Zero W together with the motor controller HAT from the CamJam Edukit #3 (from The PiHut). Here it is plugged into the powerpack from Poundland

The motor board from the CamJam kit is a very simple H-bridge that allows each motor to be powered separately backwards or forwards with it own separate power supply (AA batteries)

Next I started connecting the motor board up using the instructions from the CamJam website.

I decided to solder the wires to the battery contacts in the spider chassis but they could be attached by trapping them in the little springs.

I was later to discover that two batteries are not enough to power this robot, so I added two more batteries in a battery box much later (see later photos). You will probably want to do this at this point.

Blu Tack is your friend!

You will need some really widdly screwdrivers to attach the wires to the motor board.

You can now make the Pider walk around by remote control but to do this you will need to be able to wirelessly access the Pi Zero W. I use Real VNC to do this over wifi. You activate the Real VNC Server on the Pi Zero then you need another device to be running Real VNC Viewer.

Real VNC runs on a range of different platforms, I have it installed on my Lapdock Raspberry PI, a Windows Laptop and on a Chromebook. By preference, I use the Chromebook to access the Zero in the robot.

Next I wanted to add the ability to follow a line.

NOTE: The wires included in the CamJam kit were all white. This makes the wiring VERY difficult. So I replaced them with coloured wires. This is something that the people at The PiHut who make these kits need to consider :)

Once you have tested that the sensor is working it can be attached.

NOTE: You’ll notice that the line above is rather wide. The reason for this is twofold. Firstly, the Pider rocks from left to right as it walks. This means that if the line is too thin the Pider will see black then white, black then white as it walks. Secondly I cheated on the code and used Scratch to tell the Pider to turn left if it sees black and right if it sees white. This does work, after a fashion.

With Mr Nancy happily (just about) following a line course (after a certain amount of colourful language) it was time to add a distance sensor so that he could avoid obstructions.

To hook up the wiring and resistors for the distance sensor you have to add a breadboard to the robot. I did this by building a little platform on the back.

I also had to build a front for the sensor to be glued to.

NOTE: To begin with I used self-adhesive velcro to fix the distance sensor to the front of the motors. This fell off over night. Next I glued the sensor directly to the front of the motor not realising that this would completely gum up the motors and stop them from turning. that is when I opted (after using some choice words) to build a front piece raised forward from the motors.

Again, follow the wiring instructions from the CamJam website.

I had been increasingly concerned at how weedy the motors seemed to be. The Pider struggled to walk most of the time. I wondered if adding more batteries would help, so I added an extra battery compartment (more soldering, aarrgghh)

Success! The additional batteries transformed the Pider, so much so that there was too much power and Mr Nancy leapt all over the place. Then I had to learn how to control the power using something called pwm.

You will note that I haven’t really mentioned coding here. this is for two reasons. People have their own preferences and should really use whatever language they are most comfortable with. Also because I am so ins=experienced at coding I wouldn’t want anyone to copy my bad code.

I suggest checking out the code on the CamJam website though I used it more for inspiration. I used a combination of Scratch (for the line follower and remote control) and Python (for the distance sensor, obstacle avoidance) making use of Ben Nuttall’s excellent GPIOzero which specifically supports the CamJam Edukit #3.

Finally, you will find you have two spare sets of four legs. Each set of legs can be calibrated to take short or long steps. So I have two sets set to long and two sets set to short. You can then pull off and push on different sets of legs according to your needs :)

You are using an unsupported browser and things might not work as intended. Please make sure you're using the latest version of Chrome, Firefox, Safari, or Edge.