11:07:21 AM NPT Arduino, Robotics & IoT tutorials for Nepal
Beginner

Robotic Arm with Servos and Potentiometers (Arduino)

Build a 4-servo robotic arm controlled by potentiometers with Arduino. Separate 5 V servo supply, wiring table, smooth jitter-free code and fixes.

On this page
Robotic Arm with Servos and Potentiometers (Arduino)

A small robotic arm is one of the most satisfying beginner robotics builds. You turn four knobs, and the arm copies you: the base swings, the shoulder lifts, the elbow bends and the gripper picks up a bottle cap. It teaches analog input, servo control, mechanical design and, most importantly, power supply design, which is where most student arms fail.

This guide builds a four-servo arm controlled by four potentiometers on an Arduino Uno, with code that removes jitter and limits each joint to a safe range.

What you need

Scroll sideways to see all columns.

Item Qty Notes
Arduino Uno (or Nano) 1
Servo motors 4 SG90 for a light acrylic arm; MG90S (metal gear) for base and shoulder is better
Potentiometers 10 kΩ (linear) 4 One per joint
Separate 5 V supply for the servos 1 5 V 2 A or more, e.g. a good adapter or a buck converter from a battery pack
Electrolytic capacitor 470 µF to 1000 µF, 10 V or more 1 Across the servo supply
Robotic arm kit (acrylic or 3D-printed) 1 Or cut your own from thin board
Breadboard or small perfboard, jumper wires 1 set
DC barrel jack or screw terminal 1 For the servo supply

Bigger servos like the MG996R need much more current and a stronger frame. Start small.

Why servos need their own big 5 V supply

A servo draws little current while holding still, but when it starts moving, or pushes against a load, it can pull several hundred milliamps. Four servos starting together can easily exceed what the Arduino's 5 V pin and a laptop USB port can provide. The voltage dips, the Arduino resets, and the arm shakes or twitches. Students often blame the code for what is actually a power problem.

The fix:

  1. Power the servos from a separate 5 V supply rated for all of them together.
  2. Connect the servo supply's GND to Arduino GND, so the control signals share a reference.
  3. Put a large capacitor across the servo supply near the servos to absorb sudden current spikes.
  4. Never connect the servo supply's + to the Arduino's 5V pin.

Check the voltage rating of your servos. Most micro servos are made for about 4.8 V to 6 V. Set a buck converter to 5 V with a multimeter before connecting the servos.

Connection table

Scroll sideways to see all columns.

From To
Base pot wiper (middle pin) Arduino A0
Shoulder pot wiper Arduino A1
Elbow pot wiper Arduino A2
Gripper pot wiper Arduino A3
Each pot outer pins Arduino 5V and GND
Base servo signal (orange/yellow) Arduino D3
Shoulder servo signal Arduino D5
Elbow servo signal Arduino D6
Gripper servo signal Arduino D9
All servo red wires Servo supply + (5 V)
All servo brown/black wires Servo supply −
Servo supply − Arduino GND
Capacitor + / − Servo supply + / − (watch the polarity)
Arduino power USB or its own supply

The potentiometers are low-current and can safely use the Arduino's 5 V. Each pot is a voltage divider: turning the knob moves the wiper between 0 V and 5 V, which analogRead() turns into 0 to 1023.

Assemble the arm

  1. Centre every servo before assembly. Upload a short sketch that sets all servos to 90°, then fit the horns so each joint sits in the middle of its travel. This one step avoids most "the arm hits itself" problems.
  2. Build from the base upward: base servo, shoulder, elbow, then gripper.
  3. Keep the arm light. Every gram at the gripper is multiplied by the arm's length at the shoulder servo.
  4. Route servo wires loosely so they do not pull when the arm moves.
  5. Label the knobs: base, shoulder, elbow, gripper.

Complete code

sketch-1.inoDownload code
// 4-servo robotic arm with potentiometers - not compiled yet
#include <Servo.h>

const int NUM = 4;
const int POT_PIN[NUM]   = {A0, A1, A2, A3};
const int SERVO_PIN[NUM] = {3, 5, 6, 9};

// Safe angle range for each joint: base, shoulder, elbow, gripper
const int MIN_ANGLE[NUM] = {10, 30, 20, 40};
const int MAX_ANGLE[NUM] = {170, 150, 160, 110};

const int DEADBAND = 2;      // ignore changes smaller than this (degrees)
const int STEP = 2;          // max degrees moved per loop, for smooth motion

Servo joint[NUM];
int current[NUM];

int readAngle(int i) {
  long total = 0;
  for (int k = 0; k < 8; k++) total += analogRead(POT_PIN[i]);  // average 8 reads
  int raw = total / 8;
  return map(raw, 0, 1023, MIN_ANGLE[i], MAX_ANGLE[i]);
}

void setup() {
  Serial.begin(9600);
  for (int i = 0; i < NUM; i++) {
    current[i] = readAngle(i);       // start where the knobs are
    joint[i].attach(SERVO_PIN[i]);
    joint[i].write(current[i]);
    delay(300);                      // start servos one at a time to limit the current surge
  }
}

void loop() {
  for (int i = 0; i < NUM; i++) {
    int target = readAngle(i);
    int diff = target - current[i];

    if (abs(diff) > DEADBAND) {
      current[i] += constrain(diff, -STEP, STEP);  // move a little toward the target
      joint[i].write(current[i]);
    }
  }
  delay(15);
}

What each part does:

  • Averaging smooths the slightly noisy analog readings.
  • map() with limits means a knob turned fully can never drive a joint into the frame and stall the servo.
  • Deadband stops the servo from twitching back and forth on one-degree noise. This is the main jitter fix in code.
  • Step limit makes the arm move smoothly instead of snapping to a new position, which also reduces current spikes.
  • Staggered start in setup() avoids all four servos jumping at the same instant.

On the Uno, the Servo library uses Timer1, so analogWrite() (PWM) stops working on pins 9 and 10. That does not matter here, but remember it if you add a PWM motor later.

Find your angle limits

  1. Set all MIN_ANGLE to 90 and MAX_ANGLE to 90, upload, and check the arm sits in the middle.
  2. For one joint at a time, widen the range by 10° and test. Stop when the joint nearly touches the frame, then back off 5°.
  3. If a servo hums loudly and gets warm, it is pushing against something. Reduce that limit at once.

Upgrades

  • Record and play back. Add a button that saves the current four angles to an array, and another that replays the saved positions in order. This is a strong demo for an exhibition.
  • Phone control. Replace the pots with a Bluetooth module and a phone app, like in our Bluetooth car build.
  • Automatic sorting. Add a colour sensor and let the arm pick and drop objects by colour.

For more servo practice, see our smart dustbin and dual-axis solar tracker builds, which also use servos with a separate supply.

Troubleshooting

Scroll sideways to see all columns.

Symptom Likely cause Fix
Arduino resets when the arm moves Servos powered from the Arduino Separate 5 V supply, common GND
All servos shake together Supply too weak or no capacitor Bigger supply, add 470–1000 µF capacitor
One servo twitches constantly Noisy pot or loose wiper Increase DEADBAND; replace the pot; check solder joints
Servo hums and gets hot Pushing against the frame or overloaded Narrow its angle limits; lighten the arm
Joint moves the wrong way Pot or servo mounted reversed Swap MIN and MAX for that joint
Shoulder cannot lift the arm Servo too weak for the arm length Use a metal-gear servo; shorten or lighten the arm
Nothing moves, servos silent Servo supply GND not joined to Arduino GND Connect the grounds

FAQ

Can I power everything from one USB cable?

Only for one small servo with no load. For an arm with four servos, use a separate 5 V supply. It is the single most important part of this build.

Can I use a 9 V battery for the servos?

No. A 9 V battery is too high a voltage for most servos, and it cannot supply enough current. Use a 5 V supply or a battery pack with a buck converter set to 5 V.

Why are the pots not giving the full 0 to 180° movement?

That is intentional. The code limits each joint to a safe range. Adjust MIN_ANGLE and MAX_ANGLE for your arm.

Is a robotic arm good for a final-year project?

A pot-controlled arm suits a minor project or exhibition. For a major project, add inverse kinematics, vision-based picking or record-and-replay automation. Check your department's format.

Related tutorials

See all Robotics →