A hobby servo reads a 50 Hz pulse; the pulse width sets the angle. Enter the pulse range of your servo and the angle you want.
Ranges differ between servos. Test the limits slowly, because a servo pushed past its stop draws high current.
How it is calculated
Pulse width = minimum pulse + (maximum pulse − minimum pulse) × angle ÷ angle range. Period = 1,000,000 ÷ frequency in microseconds. Duty cycle = pulse width ÷ period. Duty count = duty cycle × (2 to the power of bits − 1).
A worked example
With a 500 to 2400 us range over 180 degrees, 90 degrees gives 500 + 1900 × 90 ÷ 180 = 1,450 us. At 50 Hz the period is 20,000 us, so the duty cycle is 1,450 ÷ 20,000 = 7.25%. With 16 bits that is a count of about 4,751.
Common mistakes
- Assuming every servo uses exactly 1000 to 2000 us.
- Using the 3.3 V pin to power the servo instead of a separate 5 V supply.
- Driving the servo to its mechanical limit and stalling it.
Related
servo torque calculator, servo not moving on ESP32, servo jitter.
Last reviewed: November 2026. The calculator runs in your browser and sends nothing anywhere. Results are ideal-case figures; add margin before you order parts.
Reading a pulse back into an angle
You can invert the formula: angle = (pulse − minimum pulse) ÷ (maximum pulse − minimum pulse) × angle range. For a servo with a 500 to 2400 us range over 180 degrees, a 1,700 us pulse gives (1,700 − 500) ÷ 1,900 × 180 = 113.7 degrees.
Another worked example
A servo with a 1,000 to 2,000 us range over 180 degrees, asked to go to 45 degrees, needs 1,000 + 1,000 × 45 ÷ 180 = 1,250 us. At 50 Hz the period is 20,000 us, so the duty cycle is 1,250 ÷ 20,000 = 6.25 percent. With a 10-bit counter (maximum value 1,023) the count is 1,023 × 0.0625 = 63.9, so use 64. With 12 bits (maximum 4,095) it is 4,095 × 0.0625 = 255.9, so use 256.
Why resolution matters
A higher bit count gives finer steps in pulse width. At 50 Hz and 10 bits, one count is about 20,000 ÷ 1,024 = 19.5 us, which is a few tenths of a degree on a typical servo. Many hobby servos also have a dead band that ignores very small changes, so extra resolution has limits.
Assumptions and limits
- The servo’s real range may differ from the datasheet. Test slowly in small steps and note the pulse where the horn starts to strain.
- Some servos accept refresh rates other than 50 Hz; check the datasheet before changing it.
- Continuous-rotation servos use the pulse to set speed and direction, not angle. The centre pulse is near the middle of the range, and the exact value needs trimming.
Common mistakes
- Using the duty cycle from this page with a PWM library that expects a different scale, such as 0 to 255.
- Powering several servos from the board’s regulator. Servos draw spikes of current when they move.