Setting Up ServoBlaster On Raspberry Pi

Project Notes for using servoblaster and webiopi on my Raspberry Pi Robot :


Start ServoBlaster at boot and have the ability to restart using init.d

Note: I’ve set this up to start and only use pins 11 and 12 by adding  –p1pins=”11,12″ after servod.
If you leave this off it will default to use all of the pins. I did it this way because the other pins were interfering with my Webiopi operation of two motors.
1. Create a file in /etc/init.d/ called servoblaster.
2. paste the code below

# /etc/init.d/servoblaster

# Provides: servoblaster
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This service is used to manage a servo

case "$1" in
echo "Starting servoblaster"
/home/pi/WebIOPi-0.7.0/examples/magpi-cambot/servod --p1pins="7,11,12"
echo "Stopping servoblaster"
killall servod
echo "Usage: /etc/init.d/servoblaster start|stop"
exit 1

exit 0

4. Make it executable

sudo chmod +x /etc/init.d/servoblaster

5. I could start it with the following:

sudo /etc/init.d/servoblaster start

…and stop it again with this one:

sudo /etc/init.d/servoblaster stop
6. Have it start every time the PI boots
sudo update-rc.d servoblaster defaults


These notes were compiled using the tutorial at the link below. Thanks Raspberrypiwebserver for posting this info:
Please note that the tutorial originally references a /etc/init.d/servoblaster file but then moves to /etc/init.d/servod later on. I have changed that in my notes above to reflect only a /servoblaster file name in /etc/init.d


I am using Webiopi for my web control of the robot, motors and servos. Webiopi is passing commands to ServoBlaster in my file. Through testing I’ve found these are my settings for the Pan and Tilt servos which hold my Pi Camera.

Lights: Servo 0 – Pin 7 / GPIO 4
I use this pin to control an LED light on the front of my vehicle

Pan: Servo 1 – Pin 11 / GPIO 17
Negative value is pan right using incremental method – echo 0=-10 > /dev/servoblaster
Positive is pan left using incremental method-  echo 0=+10 > /dev/servoblaster
Neutral is 120-   echo 0=120 > /dev/servoblaster

Tilt: Servo 2 – Pin 12 / GPIO 18
Positive value is tilt up using incremental method – echo 1=+10 > /dev/servoblaster
Negative value is tilt down using incremental method – echo 1=-10 > /dev/servoblaster
Set value 100 is 3/4 up –  – echo 1=100 > /dev/servoblaster
Neutral is 60 –   echo 1=60 > /dev/servoblaster



Project Notes: Make: A Raspberry Pi Controlled Robot by Wolfram Donat

I’ve already been building various smaller robotic vehicles using the Raspberry Pi . However, I came across a review of the book by Wolfram Donat called MAKE: A RASPBERRY PI CONTROLLED ROBOT. Building a Rover with Python, Linus, Motors and Sensors. ( Book Link ) I’ve had some trouble using higher voltage motors (from a drill), a PI camera and various servos all on a working Rover. I knew I could learn something from this book so I bought if off and starting digging in a few days later. I am soooo glad i bought this book!!

I’m currently in Chapter 6 and I’ve really learned a lot already that is going to take my Rover to the next level.
I’ll chronicle my efforts on this blog along with my project notes. Stay tuned.

Changes to Pi:

1. Added static ip to /etc/network/interfaces so that I can use the same ip to SSH into every time.

2. Created a second /etc/network/interfaces file with an Ad Hoc network. This allows the PI to create a wireless network anywhere that you can log into with a computer or mobile device even if there is not a wireless network present. Great if you are testing outside, in the woods etc….

3. Added Tight VNC Server so that I can VNC into the pi if I ever want to use the GUI Desktop.
sudo apt-get install tightvncserver

Once VNC is installed you can start from the command line on the pi with :
vncserver :1 -geometry 1024×768 -depth 16

You’ll need to install VNC on your PC or Mac and then connect to the pi with this client.

4. Installed ServoBlaster for managing the Servos on my Pi Rover.

I’ll post instructions for the 4 steps soon. Drop a comment on here if you have any questions.