Cantell STEMnet Group's Robot Snakes


We are going to make a snake that can do this...

Building the interface board

You will need

Everything must be built exactly as shown and you need to be careful to avoid shorts and dry joints.


It is quite difficult to solder the connector pins to the wires. It works like this:

  1. Strip about 3mm of insulation from the wire.
  2. position the wire so that the bare part is between the two metal tabs in the middle of the pin. The insulated part should be between the tabs at the end of the pin.
  3. Use pliers to squeeze the middle tabs against the bare wire.
  4. Carefully solder the wire in place. Make sure the solder flows over both the wire and the pin. Do not let the solder fill up the spring contact at the end of the pin.
  5. Wait for the wire to cool.
  6. Use pliers to squeeze the end tabs against the insulated part of the wire. Make this part of the connection as small as possible.
  7. If you have done "7" tightly enough, you can push the pin (spring side up) into the connector (open side up) until the pin sits completely inside the connector and the plastic tab clicks down. 


Building the Snake

The three servos just fasten together with pairs of screws. If you make the head out of Balsa wood, just cut it to shape and make two small holes with a hand drill. You can then screw two slightly larger screws directly into the Balsa; you don't need nuts.


Connecting things


Plug the USB cable into the adaptor so that the black wire on the cable is nearest the transistor. Do not connect the USB cable to the computer.

Hold the servo controller so the blue jumper is on the left side near the top. Then plug in:

Power supply

You need to set a bench power supply to 5 Volts (no more!) and, if you can, set the current limit  to 500mA. Connect the red and black power wires to the positive (+) and negative (-) terminals of the power supply. The servos might jump a little.

Computer software

You might want to practice Python programming before driving the snake; there is a good introduction here.

You need all of this software installed on your Windows PC. It's all free:

Plug in the USB cable and look in Start->Control Panel -> System -> Hardware -> Device Manager -> Ports (COM & LPT) and you should see a USB Serial Port:

Mine is COM5; you need to remember that name.

Now start up Python Start -> All Progams -> Python 2.5 -> IDLE (Python GUI) and type

  import serial
 ser =serial.Serial("COM5")

(use the name you found for the USB Serial Port) and your servo should move to the middle.

We can write a function to move the servo:
 >>> import struct
 >>> def move(servo,value):
         if value > 254: value=254

 >>> move(0,22)

move(s,p) moves servo s (which may be 0 to 7) to position p (which may be 0 to 254). 126 is about half way. If we have other servos plugged in, we can drive them using a different s argument to the move function.

We can make it move quite quickly through its range:
 >>> for pos in range(255):

Or rather more slowly:
 >>> import time
 >>> for pos in range(255):

time.sleep(x) waits for x seconds; this can be a decimal fraction. If you just want a small delay, you can just tell the servo to stay where it is:
takes about 3ms longer than

Eventually, you will want to write a program to keep. For that, you need to create a Python file, with a name something like From the Python Shell, do File -> New Window. Type your Python program in here and, when you are ready to run it, use Run -> Run Module. You will be asked to save the file before it is checked and run. Your Python program should probably start with:
   from __future__ import division
   import struct, time, serial
   def move(servo,value):
       if value > 254: value=254
Don't worry about the from __future__ bit; it just makes sure that division (/), if you use it, works as you expect.

Making the servos move further

The simple move() above only allows you to rotate the servo joints through less than 180°. You can rotate through a larger angle if you use a different protocol. Remove the blue link on the servo controller, and use this different move() function:
  def move(servo,value):
      pos=value*5000/256 +500

Value can range from 0 to 256. Here is a simple Python program which exercises the snake

Have fun.

Finally: Python is NOT named after the snake. It's named after Monty Python's Flying Circus, an old TV comedy show.

Denis Nicole.