# Arduino servo jitters or twitches: causes and fixes

> Fix an Arduino servo that jitters, twitches or resets the board: separate supply, common ground, capacitor and the pin 9 and 10 PWM side effect.

Canonical: https://roboticsengineering.in/fix/arduino-servo-jitter-twitching/ | Published: 2026-11-03 | Updated: 2026-11-04

**A servo that shakes at rest is almost always short of clean power, not short of code.** A servo draws sharp current spikes. On a shared USB or 5 V pin those spikes drag the voltage down and the signal falls apart.

## What the message means

Hobby servos need a steady supply and a stable control pulse. When the supply sags, the servo electronics misread the pulse and the horn twitches. The same sag can reset the Arduino.

## Fix it in this order

1. Power the servo from its own supply, usually 5 to 6 V, and connect its ground to the Arduino ground.
2. Do not power more than one small servo from the Arduino 5 V pin. Large servos need a proper supply.
3. Add a capacitor of about 470 to 1000 uF across the servo supply, close to the servo.
4. Keep the signal wire short and away from motor wires.
5. Call write() only when the angle changes. Writing the same angle in a fast loop adds nothing and can add noise.
6. Check the power source under load. A weak battery causes the jitter.

## One library side effect

On boards other than the Mega, the Servo library disables analogWrite() PWM on pins 9 and 10. If you use PWM on those pins for a motor, move it to another PWM pin.

## Why it happens

Servo jitter usually comes from a weak or noisy supply, a missing common ground, or a control signal that is not steady. A servo can draw a lot of current when it moves, and powering it from the board 5 V pin lets that dip disturb the board.

Power the servo from its own 5 V supply, join its ground to the board ground, and add a capacitor of about 470 µF across the servo supply. Avoid calling write() with a changing value every loop when the target has not changed.

## If you see this, do this

| You see | Do this |
| --- | --- |
| It shakes at rest | Supply noise. Separate supply, capacitor, common ground. |
| The Arduino resets when the servo moves | Servo current is sagging the board supply. |
| It buzzes at one end of travel | You are driving past its mechanical limit. Narrow the range. |

## Related

[servo motor with Arduino](https://roboticsengineering.in/servo-motor-with-arduino/), [robot battery guide](https://roboticsengineering.in/robot-battery-guide/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.

## Why this happens

A hobby servo expects a pulse about every 20 ms, with a width of roughly 1 to 2 ms that sets the angle. Its internal circuit compares that width with its position sensor and drives the motor until they match. A small change in pulse width or in the supply makes the controller correct itself, and a continuous series of tiny corrections looks like jitter.

The causes are therefore a pulse that varies, a supply that dips, or a target that really does change. A potentiometer read with analogRead() fluctuates by a few counts even when untouched, and passing that straight to write() moves the target every loop. Supply dips come from the servo’s own current pulses when it shares thin wiring or a weak 5 V source with the Arduino.

## How to confirm the cause

- Print the angle you send to write(). If the number flickers by a degree or two while nothing moves, your code is creating the jitter.
- Run a fixed-angle sketch with the servo on its own supply. If the jitter stops, the earlier cause was power or the changing input.
- Measure the servo supply at its connector while it moves, using a multimeter in min-hold mode. A dip of half a volt or more points to the supply.
- Call detach() after the move. If the twitching stops while detached, the signal or supply noise was the cause.
- Check for load. A servo holding against a heavy arm or a stop hunts back and forth.

## Worked example

This sketch sends a new angle only when it changes, so the servo is not driven by a repeated write().

```
#include <Servo.h>
Servo s;
int last = -1;
void moveTo(int a) {
  if (a == last) return;     // ignore repeats
  s.write(a);
  last = a;
}
void setup() { s.attach(9); moveTo(90); }
void loop() {
  moveTo(90);  delay(1000);
  moveTo(120); delay(1000);
}
```

If the angle comes from analogRead(), map it to degrees first and only call moveTo() when the value changes by at least 2 degrees.

## Common mistakes

- Feeding a raw analogRead() value to write() every loop.
- Sharing the supply with the Arduino and leaving the grounds unconnected.
- Using long thin wires for servo power, which adds resistance and voltage dips.
- Pushing the servo past its mechanical stop with angles outside its range.

## If this did not fix it

- Cheap or worn servo: try a second servo to see if the fault follows the part.
- Another library using the same timer: on some boards the Servo library and PWM compete.
- On an ESP32, a library written for AVR timers: use a servo library made for the ESP32.
