Introduction: Mechanical Arm

About: ElecFreaks is an open design house founded in March 2011. Our goal is to create rapid prototypes and give small-batch manufacture solution for makers and startups. With over 50% staff as engineers and expanded…

I have bought a mechanical arm before some days. Its picture looks a little cute. There are two colors for consumers to choose, black and white. I chose black one.

There are four servos for it. First one is to control its mechanical hand to catch something. The second one is to control height of its arm and hand. The third servo is to distance between mechanical and object. The last one is to control mechanical arm to turn direction, left or right.

Step 1: When You Finish the Construction, How to Make It Work?

  1. I chose an Arduino UNO board named Freaduino to control it.
  2. Connecting the first servo with D0 pin in the UNO board.
  3. Connecting the second servo with D1 pin in the UNO board.
  4. Connecting the third servo with D2 pin in the UNO board.
  5. Connecting the fourth servo with D3 pin in the UNO board.
  6. Check if every servo is working normally. At the end of the passage I will upload test code.

Now I am very carried away with how to control this mechanical arm. We can use potentiometer, rocker or Bluetooth to control it. Potentiometer is awkward to use in here. Rocker is universal and not cool enough. So I chose Bluetooth module last.

The last step, connecting Bluetooth module with board.

Step 2: Connecting Bluetooth Module With Board

Because there are four servos connected with board, we give the board extra power. If don’t do that, the USB circuit is not enough to support it.

If we want to control it by UNO board, we must put the libraries of Servo into the folder of libraries. The libraries will be uploaded at last of passage. We can use class of Servo to create four variable. Such as:

Servo Servo_Catch;

Servo Servo_Height;

Servo Servo_Distance;

Servo Servo_Direction;

And we must give them pins’ number to control corresponding servos. We use “attach” function to do it. Such as:





These are initialize of servos. The most useful function of servos is “write()”. This is to control degrees of servos. If you fill a number in the parameter, the servo will turn to the corresponding degree. For example, if I want servo of catching to turn 30 degrees, I can use it like:


Is it very easy to use? Next, let’s try to write program about how to control the mechanical arm by Bluetooth.

Step 3: Write Program About How to Control the Mechanical Arm by Bluetooth

In here, I use libraries of ElecfreaksCar directly to receive data from Bluetooth module. It will be easy if I use the libraries.

We can use class of ElecfreaksCar to create a new variable which is named BluetoothModule, such as:

ElecfreaksCar BluetoothModule;

And we use function of “recievedData()” to receive data which is from Bluetooth. We use function of “getRoll()” and “getPitch()” to get data of rocker of APP to control the mechanical arm. Now it is an example about use APP to turn on and turn off LED which is on the UNO board.

#include "ElecfreaksCar.h"
ElecfreaksCar BluetoothModule;int ledPin = 13;

void setup()
  pinMode(ledPin, OUTPUT);
void loop()
    uint8_t c =;    
    BluetoothModule.recievedData(&c, 1);  
 if(BluetoothModule.getRoll() > 125)
    digitalWrite(ledPin, LOW);  
    digitalWrite(ledPin, HIGH);  


Step 4: Modify It to Make It Can Control the Mechanical Arm by Bluetooth

Of course, we don’t use these functions to control the LED. So we modify it to make it can control the mechanical arm by Bluetooth. Now I list out functions about class of ElecfreaksCar:

getRoll(); //it will return data of roll, from 0 to 250

getPitch(); //it will return data of pitch, from 0 to 250 setFun(void (*Function)()); //it will run the sentence of Function when user presses button of APP.

This is program about the mechanical arm witch is written by me. And you can change it to create yourself program of mechanical arm.

"Servo.h</p><p>ElecfreaksCar BluetoothModule;  //define<br>a variable of class of ElecfreaksCar which is named BluetoothModule</p><p>Servo Servo_Roll;  //This is a servo which to turn direction</p><p>Servo Servo_Distance;  //This is a servo which is to control the distance between the machanical hand and object.</p><p>Servo Servo_Catch;  //THis is a servo which is to control the manchanical hand to catch or let go. </p><p>float<br>P=125.00;  //This is value of pitch. This
value is middle value when the rocker in the middle</p><p>float
R=125.00;  //This is value of roll. This
value is middle value when the rocker in the middle</p><p>unsigned char
Flag_Catch = 0;  //This is a flag about
if the machanical hand catch or not</p><p>void<br>Button()  //This function is to be run
when user touch the button of APP</p><p>{</p><p>    if(Flag_Catch == 1)</p><p>    {</p><p>        Servo_Catch.write(0);  //Catch</p><p>        Flag_Catch = 0;</p><p>    }</p><p>    else</p><p>    {</p><p>        Servo_Catch.write(90);  //let go</p><p>        Flag_Catch = 1;</p><p>    }</p><p>}</p><p>void<br>setup()</p><p>{</p><p>    Serial.begin(115200);  //baud rate</p><p>    BluetoothModule.setFun(Button);  //The arduino will run the function which is
in the parameter. In here, it will run the function of "Button"</p><p>    Servo_Catch.attach(2);  //the servo of catch is connected with pin D2</p><p>    Servo_Distance.attach(4);  //the servo of controlling distance between
machanical hand and object is connected with pin D4</p><p>    Servo_Roll.attach(5);  //the servo of controlling direction is
connected with pin D5</p><p>}</p><p>void
loop()</p><p>{</p><p>    while(Serial.available())  //if there is any data come from bluetooth,
it will into the function of while</p><p>    {</p><p>        uint8_t c =;  //read the data of serial com</p><p>        BluetoothModule.recievedData(&c,
1);  //recieve the data</p><p>       
//get the data of pitch</p><p>       
//get the data of roll</p><p>P = P *<br>0.72;  //This is important. the value of
the rocker of APP is from 0 to 250, But the degree of servo is from 0 degree to
180 degrees. </p><p>                       //So we must make the
value of pitch to multiplicative (180/250).</p><p>        R
= R * 0.72;  //the same as pitch</p><p>    }</p><p>    Servo_Distance.write((int)P);  //make the servo to run the degree</p><p>    Servo_Roll.write((int)R); </p><p>}</p>

APP Download:

Libraries Download:

For more DIY electronics projects, please visit us at:

Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest