The blue and white jumper wires
connect to the eight Raspberry Pi GPIOs
that are not used for I2C or SPI. Note the
hole where I cut the power bus.
Are we there yet???
Almost! First, I used a Dremel to drill
out one of the holes on the power bus.
This isolated the battery powered section.
I then used the long red jumper to
connect the Pi's 5V to the non-battery
Adding a 3x4 servo header and
connecting it with the right-most four
battery powered signals allows me to add
things like SeedStudio’s range sensor that
need a regulated power supply on the
Yes! We are finally there!
Note: I deliberately avoided adding jumpers to the
bottom of the board — in fact, there is only one jumper
down there; the bent lead of the LED's resistor is tack-soldered to the ground terminal on the header above it.
Just look at all the space we have left for additional
circuitry — or a even small breadboard! Okay, now that the
hardware is ready, it's time to get the Raspberry Pi loaded
with all the needed software and the demo program.
Controlling Servos and
Reading Digital Inputs
There are several excellent GPIO libraries for the Pi.
Initially, I was going to use ServoBlaster, but as it often
requires having to build a kernel module (pre-compiled
modules are not available for up-to-date Raspberry Pi
kernels), I changed my mind.
WiringPi looked great, however, its current PWM
implementation would not have given me the level of
control I wanted over the servos I am using for the robot.
I ended up using "pigpio" — an excellent, easy to use
library for C / C++ found at http://abyz.co.uk/rpi/pigpio.
Controlling the servos and reading digital inputs is a
piece of Pi with pigpio. (You thought I'd say a piece of cake,
didn't you?) There was only one minor gotcha with pigpio:
the way it measures a pulse length. The handler has to NOT
measure the length of the pulse trigger!
Fortunately, simply adding a guard variable around the
echo measurement code solved that problem. Once you
have your Raspberry Pi running, installing pigpio is easy:
Type the following lines into the console:
tar xvf pigpio.tar
You can find SPRITE related material including the
demo source code at
http://mikronauts.com/robot-zoo/sprite/. Click on sprite-demo.c to download the code.
After installing pigpio, compiling the SPRITE demonstration
software is very easy:
Type "cc -o sprite-demo sprite-demo.c -lpigpio -lrt -
To execute the demo:
Type "sudo ./sprite-demo"
I hope you enjoyed this article and that you construct
your own Raspberry Pi based robot. I really enjoyed building
SPRITE, and I will continue to improve it over time.
In the near future, I will add:
1. An analog-to-digital converter so I can use sensors
that output an analog signal.
2. A digital compass so SPRITE can use absolute and
relative compass headings.
3. A higher capacity battery pack for the motors.
4. A simple web browser based interface to the robot.
5. More demonstration code.
And much, much more!
In case you want a SPRITE of your own but prefer not
to build it on a prototyping board, Mikronauts should have
a SPRITE printed circuit board available — no need to cut
and solder jumpers.
I’m looking forward to getting your feedback on this
article at the SERVO forum. SV
SERVO 01.2014 63
Photo 10: Completed SPRITE board.