How To Assemble and Code the SparkFun Robotic Claw with Pan and Tilt for Beginners

February 22, 2013
Tags: ,

For Christmas 2012 I got the SparkFun Robotic Arm. I was unable to find any beginners guides that encompassed the full assembly and code. Here is my attempt. As a warning, I have no background experience in Arduino or electronics. Be sure to read the SparkFun product guides to know what additional equipment needs to be purchased. My build was delayed because I neglected to purchase the additional servos that do NOT come with the claw and pan/tilt hardware. I purchased the first generation of the claw. SparkFun now has a newer version of the claw (MKII) with a spring loaded clutch to protect the servo.

Claw Assembly

I would recommend following this guide ( for the assembly of the arm. I did not read these instructions the first time and it caused problems later on. Basically, you are mounting the servo so it will connect with the servo horn and claw.

UPDATE (2/22/13): I burnt up my first servo! The first generation SparkFun Claw has an alignment problem that has the potential to burn up servos. I had to replace the first servo I bought and the second generation claw has addressed this issue. On my second attempt, I added some washers to help keep the servo aligned with the claw gears.

Arm Assembly

The hardest part of the arm assembly is mounting the pan servo. SparkFun does not provide a solution for this. I made my own out of wood and Erector Set pieces.

IMG_1122 IMG_1123

When you decide on your own solution for this problem, consider the fact that the tilt servo can only go down so far. You do not want a very tall mount or you will not be able to pick up smaller objects with the claw. Making the pan servo mount compatible with the Erector Set will allow me to  add this claw to an Erector Set project.

Final Assembly

Here is a picture of the fully assembled arm.



Arduino Wiring

I wanted to control the arm with two potentiometers and two buttons. Here are pictures of the layout.

SparkFun Robotic Arm_bb

SparkFun Robotic Arm – Fritzing

IMG_1120 IMG_1121


Servo Battery Power

Having no prior electronics experience, I had no idea that the 5 volts from the Arduino Uno could not support the three servos. After a lot of googling, I discovered I needed an external battery to power the servos. I used 4 AA batteries. I bought the hardware to hold the batteries from Radio Shack.

After using the AA batteries I found that when I used all 3 servos at the same time it was not enough power. To fix this, a wall adapter was used that supplied 6 volts and 2.0 amps. With this much electricity the arm worked very well.

Wall Adapter

Arduino Code

Here is the final code I used:

Brad Poulton
Robotic Arm

#include   // servo library

Servo servo1; //base-pan
Servo servo2; //arm-tilt
Servo servo3; //claw
const int sensorPin1 = 0; // The potentiometer is connected to analog pin 0
const int sensorPin2 = 1;
int sensorValue1;
int sensorValue2;
const int button1Pin = 2;  // pushbutton 1 pin
const int button2Pin = 3;  // pushbutton 2 pin
int button1State;
int button2State;
const int ledPin =  13;   //onboard LED
int clawNum = 50; //init clawNum 

void setup()
  pinMode(button1Pin, INPUT);
  pinMode(button2Pin, INPUT);
  pinMode(ledPin, OUTPUT);
  servo1.attach(9);  //pan range is 10 to 170
  servo2.attach(10); //tilt
  servo3.attach(11); //claw range is 50 to 120
  servo3.write(clawNum);  //open claw 

void loop()
  button1State = digitalRead(button1Pin);
  button2State = digitalRead(button2Pin);
  if (button1State == LOW){
    //open claw
    digitalWrite(ledPin, HIGH);  // turn the LED on
    if (clawNum < 150){
       clawNum = clawNum + 10;
   else if (button2State == LOW) {
     //close claw
     digitalWrite(ledPin, HIGH);  // turn the LED on
     if (clawNum > 50) {
      clawNum = clawNum - 10;

  else {
    digitalWrite(ledPin, LOW);  // turn the LED off

  Serial.print("ClawNum: ");

  //read in pot values
  sensorValue1 = analogRead(sensorPin1);
  sensorValue2 = analogRead(sensorPin2);

  //map the values
  sensorValue1 = map(sensorValue1, 30, 1023, 0, 170);
  sensorValue2 = map(sensorValue2, 0, 1023, 0, 179);

  //Serial.print("Servo1: ");
  //move servo2
  //Serial.print("Servo2: ");

After doing some testing, I found the claw only had a range from about 20 to 150 before it was stopped. I ran into a problem where the servo for the claw was getting really hot and the claw was not closing. This was caused by the nuts and bolts on the claw being too tight. Another issue I ran into was the way I wired up the battery and servos. I had an extra wire connecting the battery wire and the servo wires on the breadboard. For some reason, this extra wire caused short outs and made the servos act very strange.

Check out my other code examples!

Example Code SparkFun Robotic Arm


More Example Code SparkFun Robotic Arm



In retrospect, I have concluded that this is an ambitious project for someone who has no experience with electronics. I had no idea how many AMPs the servos needed and that the Arduino was not able to supply enough electricity, but just like many of my other projects, as I overcome problems I learn a lot at the same time.



Part List


Arduino Uno R3 – $30

Sparkfun Robotic Claw – $12

Sparkfun Robotic Claw Pan/Tilt Bracket – $30

2 Medium/Standard Servos – $12/ each

2 Potentiometer – $1

Breadboard – $5

2 10k ohm Resistors (Brown Black Orange) – $1

2 Push Button Switch – $0.35

From the junk pile:

6V 2A power for servos

Miscellaneous Erector Set/ Wood pieces


2 Responses to “How To Assemble and Code the SparkFun Robotic Claw with Pan and Tilt for Beginners”

  1. What is the 2 Resistor you used? A link to from where you purchased them would be great.

  2. Sham,

    I have updated the post with the URL to the 10k ohm resistors. If you are interested in a starter kit I have liked the SparkFun Inventor’s Kit, although it is pricey at $100.

Leave a Reply