Basic Robotic Arm

We have previously connected the servo motor with Arduino, now we will build a robotic arm using Arduino, robotic arm It has many uses in the entertainment and industry, such as factory automation. To build a simple robot arm you will need 4 servo motors and the latest version of Arduino Software (IDE). if you use older versions you need to download a Servo library. and we need the following component’s:  

Arduino UNO R31
Potentiometers 10K4
Servo motors (any type support +5DC)4
Bread board 1
wires 20

How will the program work? 

We studied the servo motors so to control them, we need to use the pulse width modulation PWM. we will use in variable resistance Potentiometers (10K) using variable resistance will change the angle of the servo motor, in the code we will define the motors and resistors and determine the range from 0 to 1024 according to the motor and Arduino datasheet. But what is potentiometer?

Potentiometer it is variable resistance but its value can be changed manually using knob since the increase of resistance will reduce the current , this piece is used for example in the control of the volume in radio, in our project we use to control the degree of servo motor. There are many types of them, some of which moves in a linear and some moves in a rotating, the following picture shows some types:

In our project, you can choose any type but it should be worth 10k ohm, However, we recommend that you use the circular type because it is more flexible and gives greater control accuracy, such as this type:

Circular Potentiometer
Circular Potentiometer

Schematic Diagram

In this project, we will connect the servo motor to the following digital output that support PWM (D3, D5, D6, and D7), And connect the potentiometer to the following analog inputs (A0, A1, A2, and A3). Connections of servo motors and potentiometer with Arduino UNO R3 it will be as follows :


Make sure your connections are correct then connect Arduino with PC using USB then upload this code to Arduino Uno board or any board you own:

//this code from ;
#include <Servo.h>

//Servo Motors Defintion

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;

//Potentiometers Defintion

int pot1 = A0;
int pot2 = A1;
int pot3 = A2;
int pot4 = A3;

int valPot1;
int valPot2;
int valPot3;
int valPot4;

void setup()

servo1.write(0); //define servo1 start position
servo2.write(90); //define servo2 start position
servo3.write(90); //define servo3 start position
servo4.write(70); //define servo4 start position

void loop()
// potentiometers (value between 0 and 1023)

valPot1 = analogRead(pot1);
valPot1 = map (valPot1, 0, 1023, 90, 180); //(servo value between 0 and 180)

valPot2 = analogRead(pot2);
valPot2 = map (valPot2, 0, 1023, 0, 180);

valPot3 = analogRead(pot3);
valPot3 = map (valPot3, 0, 1023, 0, 180);

valPot4 = analogRead(pot4);
valPot4 = map (valPot4, 0, 1023, 0, 180);


Now change the values of potentiometers (clockwise or counter clockwise) and watch the servo motors move, you can now design a frame that suits you to hold things around you and you can modify the code to add more servo motors.

Note: If you are using a 5V servo motor, you do not need an external power unit, because the USB computer is capable of providing you with sufficient power, so don’t worry about power.

Leave a Reply

Adblock Detected

Please consider supporting us by disabling your ad blocker