You interface a standard hobby servo with an Arduino by connecting its signal wire to a PWM-capable digital pin (like Pin 9), powering it with an external 5V-6V supply, and using the built-in <Servo.h> library to send pulse widths between 500 and 2400 microseconds. The servo's internal H-bridge and potentiometer handle the closed-loop position control automatically.
While the code is trivial, the hardware integration is where most projects fail. Beginners routinely fry their Arduino's onboard voltage regulator or experience endless reset loops because they ignore servo stall current. A mid-sized servo can pull 2.5A under load, which will instantly overwhelm the 800mA limit of an Arduino Uno's linear regulator. This guide covers the exact wiring, sizing math, and failure signatures you need to run servos reliably on the bench.
Motor Selection: Why a Servo and Not a Stepper?
Before wiring anything, confirm a servo is actually the right tool for your load profile. Hobbyists often treat steppers and servos as interchangeable, but they solve fundamentally different mechanical problems. Servos excel at high-torque, low-speed, closed-loop positional tasks (like robotic arms or camera gimbals). Steppers excel at open-loop, continuous precision movement (like 3D printer axes).
| Motor Type | Torque Curve | Control Needs | Cost (Typical) | Best Load Profile |
|---|---|---|---|---|
| RC Servo | High at zero speed (stall), drops as speed increases | 50Hz PWM signal, internal closed-loop driver | $3 - $25 | Finite angular movement, high holding torque, low inertia |
| Stepper | High at low speed, drops sharply at high RPM | Step/Dir pulses, external H-bridge driver (e.g., A4988) | $10 - $40 | Continuous rotation, precise open-loop positioning |
| Brushed DC | Peak at stall, linear drop to zero at no-load speed | H-bridge for direction, PWM for speed control | $5 - $20 | Continuous high-speed rotation, low holding torque |
If your application requires moving a specific angle and holding it there against gravity, the servo is the correct choice. Below is a spec-sheet breakdown of the most common hobby servos used with Arduino boards in 2026, highlighting the massive gap in current draw and torque between micro and standard sizes.
| Model | Gear Material | Stall Torque (at 6V) | Stall Current | Weight | Price Range |
|---|---|---|---|---|---|
| SG90 | Plastic | 1.8 kg-cm (0.18 Nm) | ~650 mA | 9g | $2 - $4 |
| MG90S | Metal | 2.2 kg-cm (0.22 Nm) | ~800 mA | 13g | $4 - $7 |
| MG996R | Metal | 11.0 kg-cm (1.08 Nm) | ~2.5 A | 55g | $8 - $12 |
| DS3218 | Metal | 20.0 kg-cm (1.96 Nm) | ~3.0 A | 60g | $15 - $22 |
Wiring, Terminals, and the Brownout Trap
Standard hobby servos use a 3-wire interface. While the functions are universal, the wire colors vary slightly by manufacturer. Always verify the pinout on the servo's datasheet, but the industry standard (JR/Futaba style) follows this pattern:
- Brown or Black: Ground (GND)
- Red: Power (VCC, typically 4.8V to 6.0V)
- Orange, Yellow, or White: Signal (PWM input)
When using an external power supply for your servos, you must connect the ground of the external power supply to the GND pin of the Arduino. The Arduino's PWM signal is a voltage reference; without a shared ground, the servo sees a floating signal and will jitter violently or sweep to its mechanical hard stop.
The Power Isolation Requirement
Never power an MG996R or larger servo directly from the Arduino's 5V pin. The Arduino Uno's onboard NCP1117 linear regulator is rated for roughly 1A absolute maximum, and that assumes adequate heat sinking. When a standard servo hits a mechanical bind, it draws stall current (2.5A+). This will either trigger the regulator's thermal shutdown (causing the Arduino to reset) or permanently melt the PCB traces.
Instead, use a separate 5V power source. For bench testing, a dedicated 5V 3A bench supply works perfectly. For battery-powered builds, use a BEC (Battery Eliminator Circuit) or an LM2596 buck converter stepped down to exactly 5.0V from your main LiPo or 12V battery pack. Wire the BEC's 5V and GND directly to the servo, and wire the BEC's GND to the Arduino's GND. Only the signal wire connects to the Arduino's digital pin.
Sizing Rule of Thumb and Worked Load Example
A common mistake is sizing a servo based exactly on its rated stall torque. Stall torque is the absolute maximum force the motor can exert right before it stops moving. Running a servo continuously near its stall torque will overheat the internal DC motor and strip the gears.
The Sizing Rule of Thumb: Apply a 3:1 safety factor for continuous static loads, and a 5:1 safety factor for dynamic loads with high inertia (fast starts and stops).
Worked Example: Robotic Arm Forearm
Suppose you are building a robotic arm. The forearm is 15 cm (0.15 m) long, and it needs to lift a 200 g (0.2 kg) payload at the very tip. We will ignore the weight of the arm itself for simplicity, though in practice you must add the arm's center of mass to the calculation.
- Calculate Force: Force = mass × gravity. 0.2 kg × 9.81 m/s² = 1.96 Newtons.
- Calculate Required Torque: Torque = Force × distance. 1.96 N × 0.15 m = 0.294 Nm (roughly 3.0 kg-cm).
- Apply Safety Factor: For a static hold, multiply by 3. 3.0 kg-cm × 3 = 9.0 kg-cm minimum required torque.
Based on our spec table, the SG90 (1.8 kg-cm) and MG90S (2.2 kg-cm) will fail instantly. The MG996R (11.0 kg-cm) provides just enough headroom, but if the arm moves quickly (dynamic load), you should step up to the DS3218 (20.0 kg-cm) to prevent gear stripping and motor overheating. For deeper mechanical sizing frameworks, refer to the ServoCity Servo FAQ and Sizing Guide.
Arduino Code, Control, and Failure Signatures
Standard hobby servos demand a 50Hz PWM signal. The position is dictated by the pulse width: typically 500 microseconds (0°), 1500 microseconds (90°), and 2500 microseconds (180°). The Arduino <Servo.h> library handles this timing automatically. You do not need an external motor shield or driver board for 1 or 2 servos; the microcontroller's digital pins can source the few milliamps required to drive the servo's internal control logic.
#include <Servo.h>
// Define the servo object and the PWM pin
Servo myServo;
const int SERVO_PIN = 9; // Pin 9 supports hardware PWM on Uno/Nano
void setup() {
// Attach the servo to the pin
myServo.attach(SERVO_PIN, 500, 2400);
// The 500 and 2400 parameters calibrate the min/max pulse widths
// to match your specific servo's physical travel limits.
}
void loop() {
// Move to 0 degrees
myServo.write(0);
delay(1500); // Wait for the servo to reach the position
// Move to 90 degrees
myServo.write(90);
delay(1500);
// Move to 180 degrees
myServo.write(180);
delay(1500);
}
For more advanced multi-servo control without blocking the main loop with delay(), look into the Arduino Servo Library Documentation or the third-party VarSpeedServo library.
Diagnosing Failure Signatures
When a servo misbehaves, it usually gives you physical feedback before it dies completely. Here is how to read those symptoms:
- Humming or Jittering in Place: This is rarely a code issue. It usually indicates a noisy power supply, a missing common ground, or a worn-out internal potentiometer. If the jitter happens only when a specific motor or LED turns on, you have voltage sag on your 5V rail. Add a 470µF electrolytic capacitor across the servo's VCC and GND wires to smooth out transient voltage drops.
- Overheating (Smell of Hot Plastic): The servo is holding a heavy static load near its stall torque. The internal DC motor is drawing stall current continuously but cannot move, turning electrical energy entirely into heat. You must either reduce the load, add a mechanical brake, or upgrade to a higher-torque servo.
- Clicking or Grinding: You have either stripped the internal gears (extremely common with the plastic SG90 under any real load) or you are commanding an angle beyond the servo's physical hard stop. Many "180-degree" servos only have 120 to 140 degrees of actual physical travel. Commanding 180° forces the motor to drive the gears into the mechanical end-stop, causing a loud clicking sound and immediate gear damage. Use the
attach(pin, min, max)calibration to limit the software travel to the physical limits.






