Projects / Servo sweep and calibration

Servo sweep and calibration

Beginner30 minGuided buildReviewed

Build it step by step

0 of 7 done
  1. UNO59°

    Wire the servo

    Connect power, ground and signal, with the capacitor near the servo.

  2. UNO

    Sweep first

    Set SWEEP_MODE to true and watch the arm move 0 to 180.

  3. UNO

    Find where it stalls

    Listen for buzzing at either end.

  4. UNO

    Narrow the limits

    Raise MIN_US and lower MAX_US until the buzzing stops.

  5. UNO

    Switch to pot control

    Set SWEEP_MODE to false and turn the pot.

  6. UNO59°

    Check the range

    The pot's full travel should use the whole safe servo range.

  7. UNO59°

    Remove the capacitor

    See if the Uno resets or the servo jitters when it moves.

In short

How do you build a servo sweep and calibration?

Sweep a servo, find its real end points and map a pot to the full safe range. You need Arduino Uno R3, SG90 Micro Servo, Potentiometer 10 kΩ, Electrolytic Capacitor 100 µF, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 7 steps and about 30 minutes.

Level
Beginner
Time
About 30 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Servo red wireUno 5VServo power
Servo brown or black wireUno GNDGround
Servo orange or yellow wireUno D9Signal
100 µF capacitorAcross 5V and GND near the servo, + on 5VAbsorbs the current surge
Potentiometer outer pins5V and GNDReference
Potentiometer wiperUno A0Position input

Code

Hobby servos are driven by a pulse every 20 ms whose width sets the angle, about 1 ms for one end, 1.5 ms for the middle and 2 ms for the other, but cheap servos differ. MIN_US and MAX_US set the limits the library uses. If the servo buzzes at an end, it is pushing against its stop: reduce the limits a little. A small servo like an SG90 can run from the Uno 5 V pin for light loads; for larger servos use a separate 5 V supply with a shared ground. Keep the servo clear of obstacles when testing, and do not hold the horn. Arduino IDE, board "Arduino Uno" (or "Arduino Nano" with processor ATmega328P).

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Sweep, then pot control, with pulse limits you can change after finding the real end points.
#include <Servo.h>

Servo s;
const int MIN_US = 600;     // start safe, then widen: standard is about 544
const int MAX_US = 2300;    // standard is about 2400
const byte POT = A0;
const bool SWEEP_MODE = false;   // true = sweep test, false = follow the pot

void setup() {
  s.attach(9, MIN_US, MAX_US);
  Serial.begin(9600);
}

void loop() {
  if (SWEEP_MODE) {
    for (int a = 0; a <= 180; a++) { s.write(a); Serial.println(a); delay(20); }
    for (int a = 180; a >= 0; a--) { s.write(a); Serial.println(a); delay(20); }
  } else {
    int angle = map(analogRead(POT), 0, 1023, 0, 180);
    s.write(angle);
    delay(15);
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
SweepSmooth movement from end to end
Limits set correctlyNo buzzing at either end
Pot turnedServo follows
Capacitor removed under loadMore jitter or resets

If it does not work

Servo jitters

Add the capacitor or use a separate 5 V supply.

Buzzes at an end

Narrow the pulse limits.

Does not move

Check the signal pin 9 and the ground connection.

Uno resets

The servo draws too much; use an external supply.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the servo sweep and calibration?

Arduino Uno R3, SG90 Micro Servo, Potentiometer 10 kΩ, Electrolytic Capacitor 100 µF, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).

How long does the servo sweep and calibration take to build?

About 30 minutes for a beginner maker, in 7 steps.

How do I know the servo sweep and calibration works?

Sweep: Smooth movement from end to end. Limits set correctly: No buzzing at either end. Pot turned: Servo follows.

Servo jitters: what should I check?

Add the capacitor or use a separate 5 V supply.

Buzzes at an end: what should I check?

Narrow the pulse limits.

Does not move: what should I check?

Check the signal pin 9 and the ground connection.

Uno resets: what should I check?

The servo draws too much; use an external supply.