How to control Servo robotic arm using potentiometers

How to control 4 servo of Servo robotic arm using 4 potentiometer (Variable resistors)

Use 4 potentiometers (variable resistors) to control your robotic arm by varying the position of potentiometer knob.

What do you need?

  • Servo robotic arm
  • 4 Potentiometers (2k var)
  • Breadboard
  • Arduino UNO
  • Jumper wires
  • Power unit for Arduino

STEP 1: ARDUINO CODE

Upload the code to your arduino.

// Controlling 4 servo motors using 4 separate potentiometers (variable resistor)
// by Servo Robotic Arm <http://www.ServoRoboticArm.wordpress.com&gt;

#include <Servo.h>

Servo myservo; // create servo object to control a servo
Servo ser1;
Servo ser2;
Servo ser3;

int con1 = 0; // analog pin used to connect the potentiometer
int con2 = 1;
int con3 = 2;
int con4 = 3;
int val; // variable to read the value from the analog pin
int val1;
int val2;
int val3;

void setup()
{
myservo.attach(7); // attaches the servo on pin 9 to the servo object
ser1.attach(6);
ser2.attach(5);
ser3.attach(4);
}

void loop()
{
val = analogRead(con1); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
val1 = analogRead(con2);
val1 = map(val1, 0, 1023, 0, 179);
val2 = analogRead(con3);
val2 = map(val2, 0, 1023, 0, 179);\
val3 = analogRead(con4);
val3 = map(val3, 0, 1023, 0, 179);

myservo.write(val); // sets the servo position according to the scaled value
ser1.write(val1);
ser2.write(val2);
ser3.write(val3);
delay(15); // waits for the servo to get there
}

STEP 2: CONNECTION

Connect 4 servo with Arduino and 4 potentiometer as shown in following connection diagram.

Arduino Servo robotic arm.jpg

Connect:

  • 1st terminal of all 4 potentiometers with +5v
  • 3rd terminal of all 4 potentiometers with GND
  • Middle terminal of potentiometer 1, 2, 3 and 4 with A0, A1, A2 and A3
  • Red wire of all 4 servo with +5 v
  • Black/Brown wire of all 4 servo with GND
  • Yellow wire of gripper micro servo with pin 4
  • White wire of right servo with pin 5
  •  White wire of center servo with pin 6
  • White wire of left servo with pin 7

STEP 3: POWER

Give proper supply to your arduino and control your robotic arm by varying the position of potentiometer knob.

Other method of control: Please note that the robotic arm uses 4 servo, so you can also use any other control method compatible for 4 servo motors.

Link for smartphone/bluetooth controlled servo arm

Link for multi servo control with smartphone

Link for basic introduction to Multiple Servo Control With Joystick

Link for code to control 4 servo with 2 Joystick

Link 2 for code of 4 servo control with 2 joystick

Leave a Reply

Your email address will not be published. Required fields are marked *