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



Leave a Reply