The standard Arduino Servo library outputs a 50Hz PWM signal designed exclusively for hobby RC servos (like the SG90 or MG996R) that contain internal feedback potentiometers. It handles the 20ms period and 1-2ms pulse width timing via hardware interrupts, making it trivial to command an angle. However, if your load requires continuous rotation, high holding torque at zero speed, or precise multi-axis coordination, you must abandon the Servo library and switch to stepper motors with dedicated chopper drivers (like the TMC2209) or brushless DC (BLDC) motors with ESCs. Treating these motor types as interchangeable is the most common cause of stripped gears and burnt driver boards in embedded projects.

Sizing RC Servos for Your Load (Worked Example)

The golden rule of servo sizing is to calculate the stall torque required at the furthest lever arm, then add a 50% safety margin for dynamic loads and inertia. RC servos are rated in kg-cm or oz-in, which represents the maximum weight they can hold at a 1cm (or 1 inch) distance from the output shaft center before stalling.

Rule of Thumb: Never size a servo for exactly the calculated static load. The internal potentiometer will constantly hunt around the target position under a 100% load, causing jitter, overheating, and premature gear wear. Always aim for a servo rated at 1.5x to 2x your calculated requirement.

Worked Load Example: Imagine you are building a robotic arm that needs to lift a 200g payload at the end of a 15cm (0.15m) forearm.

  • Force: Mass × Gravity = 0.2kg × 9.81 m/s² = 1.96N
  • Torque: Force × Distance = 1.96N × 0.15m = 0.294 Nm (approximately 3 kg-cm)
  • Safety Margin: 3 kg-cm × 1.5 = 4.5 kg-cm required

If you select a standard micro servo like the SG90 (rated at 1.8 kg-cm), it will immediately stall and strip its plastic gears. You need a metal-gear servo like the MG996R, which is rated for roughly 10 to 13 kg-cm at 6V, to handle this safely. Furthermore, never power an MG996R directly from the Arduino's 5V pin. It can draw up to 2.5A on stall, which will instantly trip the Arduino's polyfuse or fry the onboard AMS1117 voltage regulator. Use a dedicated 5V/6V BEC (Battery Eliminator Circuit) or a high-current buck converter.

Motor Type Comparison: RC Servos vs. Steppers vs. Brushed DC

Choosing the right motor dictates your entire control architecture. Below is a comparison of the three most common actuator types in hobbyist and prosumer embedded systems to help you determine which motor type fits your specific load profile.

Motor Type Torque Curve Profile Control Needs & Library Relative Cost Best Fit Load Profile
RC Servo (via Arduino Servo Lib) High torque at low speeds, drops sharply at high RPM. Excellent holding torque via internal feedback. 50Hz PWM signal. Requires Servo.h. No external driver needed. $3 - $25 Jointed robotic arms, pan/tilt camera mounts, RC steering linkages.
Stepper (e.g., NEMA 17 + TMC2209) Massive holding torque at zero speed, drops significantly above base RPM. Open-loop (usually). Step/Dir pulses. Requires external chopper driver and AccelStepper or FastAccelStepper. $15 - $45 3D printers, CNC routers, linear actuators, precise conveyor indexing.
Brushed DC (with H-Bridge) Low starting torque, peaks at mid-RPM. No inherent position feedback. Continuous PWM (1kHz-20kHz) + H-Bridge for direction. Requires motor driver IC. $5 - $20 Wheeled mobile robots, winches, high-speed flywheels, continuous conveyors.

If your application demands exact angular positioning over a limited range (typically 180 degrees) without complex homing routines, the RC servo is the correct choice. If you need continuous rotation with precise positional tracking over multiple revolutions, you must use a stepper motor. For a deeper dive into stepper torque curves and pull-out torque limits, refer to this guide on stepper motor selection from All About Circuits.

Wiring, Terminals, and Driver Demands

The physical wiring and driver requirements for these motors are fundamentally different. Confusing them will result in dead shorts or bricked microcontrollers.

RC Servo Wiring (Arduino Servo Library)

Standard hobby servos use a 3-pin JR-style connector:

  • Brown or Black: Ground (GND). Must be tied to both the external power supply ground and the Arduino GND.
  • Red: VCC (typically 4.8V to 6.0V). Connect to the positive terminal of your external BEC or battery pack.
  • Orange, Yellow, or White: Signal (PWM). Connect to any digital pin on the Arduino (e.g., Pin 9).

Critical Demand: The Arduino Servo library handles the timing, but the microcontroller GPIO pin only provides the logic-level signal (3.3V or 5V). It does not source the current to move the motor. The common ground connection between the Arduino and the external power supply is mandatory; without it, the PWM signal has no reference voltage and the servo will twitch violently.

Stepper Motor Wiring (Step/Dir Drivers)

Bipolar stepper motors (like a NEMA 17) have 4 wires, usually organized as two coils (A and B). You cannot connect these directly to an Arduino. They demand an external chopper driver (like the A4988, DRV8825, or TMC2209). The Arduino only sends low-current STEP and DIR logic signals to the driver, while the driver handles switching the high-current (often 1.5A to 2.5A) coil power using microstepping algorithms. Libraries like AccelStepper are required to generate the acceleration ramps; the standard Servo library cannot generate the high-frequency pulse trains required for steppers.

Failure Signatures: Diagnosing Hum, Overheat, and Stall

Motors communicate their failure modes through sound, temperature, and motion. Recognizing these signatures early prevents hardware destruction.

  • Hum and Jitter (Servo): If your MG996R hums and twitches at the target angle, the power supply is browning out under load, or the ground wire is too thin (causing a voltage drop on the signal reference). Upgrade your power bus to at least 18 AWG wire and ensure your BEC can supply 2A per servo.
  • Overheat (Servo & Stepper): RC servos overheat when mechanically stalled against an obstruction while still receiving a PWM signal. The internal H-bridge continuously applies full voltage to the DC motor trying to reach an impossible target, dumping current as heat. Steppers, conversely, run hot by design (50°C-70°C casing temperature is normal). However, if you cannot keep your finger on the stepper casing for 3 seconds, the VREF current limit on your driver is set too high. Adjust the driver's trimpot while measuring the VREF pin with a multimeter.
  • Stall and Missed Steps (Stepper): A stepper stalls when the load inertia exceeds the motor's pull-out torque at that specific RPM. You will hear a distinct grinding or clicking sound as the rotor skips magnetic poles. Fix this by implementing acceleration ramps in your code, reducing the microstepping divisor, or gearing down the output to multiply torque.
  • Grinding Noise (Servo): A continuous ratcheting or grinding sound from an RC servo usually indicates stripped internal gears (common in plastic-gear SG90s under heavy load) or a sheared output spline. The motor is spinning, but the output shaft is no longer coupled to the gear train. Replacement is the only fix.

Arduino Servo Library FAQ

Can I use the Arduino Servo library to control a brushed DC motor?

No. The Servo library outputs a 50Hz pulse (1000-2000µs width) specifically formatted for a servo's internal control board to interpret as an angle. A standard brushed DC motor requires a continuous, higher-frequency PWM signal (typically 1kHz to 20kHz) fed into an H-Bridge motor driver (like an L298N, TB6612FNG, or BTS7960) to control speed and direction. Sending a 50Hz signal to an H-Bridge will just make the DC motor stutter and click 50 times a second.

Why does my servo twitch when using the Arduino Servo library with an ESP32?

The standard Arduino Servo library relies on hardware timers (like Timer1 on the ATmega328P) that conflict with the ESP32's dual-core architecture and FreeRTOS task scheduling, causing severe PWM jitter. For ESP32 boards, you must use the ESP32Servo library. This fork utilizes the ESP32's native LEDC (LED Control) hardware PWM channels, bypassing software interrupts to generate a rock-solid 50Hz signal that eliminates servo twitching.

How many servos can the Arduino Servo library control simultaneously?

On an ATmega328P (Arduino Uno/Nano), the library can theoretically support up to 12 servos using a single hardware timer. However, the practical limit is dictated entirely by your external power supply's amperage and the gauge of your ground bus wire, not the microcontroller's pin count. If you attempt to move four MG996R servos simultaneously under load, they can draw a combined 10A. If your breadboard jumper wires or power traces cannot handle this current, the voltage will sag, the servos will stall, and the Arduino will brownout and reset.

What happens if I send a 180-degree command to a 90-degree servo?

The servo will drive to its physical hard stop and stall. Because the internal potentiometer will never reach the requested 180-degree feedback value, the internal control board will continuously apply full voltage to the DC motor in a desperate attempt to close the error loop. This will rapidly overheat the motor, strip the gears against the hard stop, or burn out the internal driver MOSFETs. Always use the attach(pin, min_us, max_us) function to map your software commands to the specific physical limits of your exact servo model.