Skip to content

Servo · Arduino Uno guide

Controlling MG996R Metal Gear Servo Motor with Arduino Uno

A metal-gear, 10 kg·cm hobby servo for robot arms, steering and pan/tilt. Strong, but it needs its own 5 to 6 V supply.

Updated November 14, 2026 Arduino C++ServoAlso forESP32

What is the MG996R?

The MG996R is the go-to "big" hobby servo: a standard-size positional servo with metal gears and around 10 kg·cm of torque, several times the strength of the little SG90. You send it a pulse, it turns its output shaft to the matching angle and holds it there against a load. That makes it the default choice for robot arm joints, RC steering, pan-and-tilt camera mounts, door latches and walking robots.

That strength has a price: it can draw over 2 A when it stalls, which is more than any Arduino or ESP32 board can supply. Almost every MG996R problem (jitter, resets, a board that will not boot) is a power problem. This page explains how a servo turns a pulse into an angle, the specs that matter, how to power one or several safely, how to tell a genuine unit from a weak clone, and how it compares with other servos. For code, see the Arduino Uno guide and the ESP32 guide.

Specifications

Type
Positional (standard) servo, about 180° travel; continuous-rotation versions are sold separately
Operating voltage
4.8 to 7.2 V (6 V is the sweet spot)
Stall torque
About 9.4 kg·cm at 4.8 V, 11 kg·cm at 6 V
Speed
About 0.17 s per 60° at 4.8 V, 0.14 s per 60° at 6 V (no load)
Current
About 10 mA idle, 0.5 to 0.9 A moving, up to about 2.5 A stalled at 6 V
Control signal
PWM at 50 Hz (20 ms frame); pulse width sets the angle
Pulse range
Roughly 0.5 to 2.5 ms end to end; varies by unit
Dead band
About 5 µs
Gears
Metal, with dual ball bearings on the output shaft
Signal level
3.3 V or 5 V logic both work in practice
Size / weight
About 40.7 × 19.7 × 42.9 mm, 55 g

From the TowerPro MG996R datasheet. Many MG996Rs on the market are clones with lower torque and wider tolerances: treat these as best-case figures and test your own unit.

Wires

WireNameConnect to
BrownGNDServo supply ground, joined to the microcontroller's GND
RedV+Servo supply positive, 4.8 to 7.2 V. Not the board's 5V pin
OrangeSignalA PWM-capable GPIO (Uno D9, ESP32 GPIO18 in the guides)

Swipe sideways to see every column →

Colours follow the TowerPro convention; some clones use black / red / white or yellow. The middle wire is almost always power.

Wiring & code

Setting up MG996R with Arduino Uno

Library

Servo by Arduino (built in)

Built into the Arduino IDE, no install needed

This guide connects an MG996R servo to an Arduino Uno the safe way, with its own power supply, and builds up in three steps: a sweep test, a limit finder that tells you exactly how far your particular servo can travel, and smooth potentiometer control that eases into position instead of snapping. The specs, power sizing and servo comparison are on the MG996R overview.

What you need

QtyPartNotes
1Arduino Uno R3 (or Nano)Any 5 V Arduino; the Servo library is built in
1MG996R servoTest it unloaded first
15 to 6 V supply, 3 A or moreA 5 V 3 A adapter, or a 6 V NiMH pack
1470 to 1000 µF capacitor, 10 V or higherAcross the servo's power wires
110 kΩ potentiometerOnly for Sketch 3

Swipe sideways to see every column →

Wiring: MG996R to Arduino Uno

Servo wireConnect toNotes
Brown (GND)Servo supply − and Uno GNDThe grounds must be joined
Red (V+)Servo supply + (5 to 6 V)Not the Uno's 5V pin
Orange (signal)Uno D9Any digital pin works; D9 is the convention
CapacitorAcross red and brown, near the servoWatch the polarity: stripe to brown (GND)

Swipe sideways to see every column →

Warning

Do not power an MG996R from the Uno's 5V pin, even for a quick test. A stalled MG996R draws about 2.5 A; USB gives 0.5 A. The usual result is a reset loop, and you can damage the USB port or the Uno's 5 V regulator.

Sketch 1 - Sweep test

Moves the servo slowly from 0° to 180° and back, one degree at a time. Leave the horn off or unloaded: you are checking that it moves smoothly over its whole range without buzzing at the ends.

C++

Why attach(9, 500, 2500)? By default the library maps 0 to 180° onto 544 to 2400 µs, which leaves many MG996Rs well short of their full travel. Giving it 500 to 2500 µs lets write(0) and write(180) reach further, which is also why the next sketch matters: at these extremes some units hit their internal stop. If the servo buzzes at 0° or 180°, it is pushing against that stop; Sketch 2 finds where to stop instead.

Sketch 2 - Find your servo's safe limits

Every MG996R, and every clone, has a slightly different pulse range. This sketch lets you type a pulse width in microseconds into the Serial Monitor and moves the servo there, so you can find the lowest and highest values it reaches without buzzing. Write them down: they are the limits for every later sketch, and they protect the servo and your linkage.

C++
  1. 1Upload, open the Serial Monitor at 9600 baud and choose 'Newline'.
  2. 2Type 1500: the servo goes to its centre. Fit the horn so it points where you want 'centre' to be.
  3. 3Type 1300, 1100, 900... in steps of 100, then 50, listening at each step. The first value where it buzzes or stops moving is past the limit: your minimum is the last quiet value.
  4. 4Repeat upwards from 1500 (1700, 1900, 2100...) to find the maximum.
  5. 5Note both numbers, for example 600 and 2400. Keep the servo away from them in normal use by 20 to 50 µs.

Sketch 3 - Smooth control with a potentiometer

A servo jumps to each new position at full speed, which looks jerky and stresses gears and linkages. This sketch reads a potentiometer and eases towards it: each update moves 8 % of the remaining distance, so the arm accelerates and settles smoothly. It also keeps the servo inside the limits you found in Sketch 2.

Extra wiring for Sketch 3

Potentiometer pinUno pinNotes
Outer leg5V
Wiper (middle)A0
Outer legGND

Swipe sideways to see every column →

C++

Tuning the feel. The 0.08 factor sets how quickly it follows: 0.03 is slow and silky, 0.2 is snappy. Because the motion slows near the target, the servo also stops hunting back and forth around a noisy potentiometer reading. The same easing line works for any target: a sensor, a serial command or a value received over Bluetooth.

Troubleshooting on the Uno

SymptomLikely causeFix
Uno resets as soon as the servo movesServo powered from the UnoSeparate supply; join only the grounds
Servo twitches, never settlesGrounds not joinedConnect the supply's negative to the Uno's GND
Only about 90° of travelDefault 544 to 2400 µs limitsattach(9, 500, 2500), then fine-tune with Sketch 2
Buzzes at the end of a sweepCommanded past the mechanical stopUse your measured limits
Servo slow and weak4 × AA alkaline pack sagging5 V 3 A adapter or NiMH / regulated 6 V
Other servo libraries stop working with Servo.hTimer 1 conflict (Servo uses it on the Uno)Avoid analogWrite on D9 and D10 while servos are attached

Swipe sideways to see every column →

Arduino Uno FAQ

Can I control several MG996Rs from one Uno? Yes, one pin each (up to 12 with the Servo library), all powered from one adequately sized supply. Note that while any servo is attached, analogWrite() no longer works on pins 9 and 10.

How do I make the servo hold its position when the Uno resets? It cannot: without pulses it goes limp, and at power-up it may jump to wherever the first pulse says. Start every sketch by writing the position the mechanism is already in, and power the servo up after the Uno where you can.

Can I use the Uno R4? Yes. The Servo library supports the R4, and the wiring is the same.

Where next? Control the servo from your phone with the MG996R ESP32 guide, or lock and unlock it with an RFID card using the RC522 Uno guide.

Keep learning

Related guides & projects