How to use the servo pulse width calculator
- Choose your servo type. SG90 / MG90S micro servos usually need about 500–2500 µs for their full travel; many standard servos use 1000–2000 µs. Pick Custom to enter your own limits.
- Check the travel (usually 180°) and the signal frequency (50 Hz for almost every hobby servo).
- Type an angle (or drag the slider) to get the pulse width — or type a pulse width to see which angle it gives.
- Copy the
writeMicroseconds()value for the Arduino Servo library, or theledcWrite()value for an ESP32 at the resolution you choose.
How a servo signal works
A hobby servo does not care about the duty cycle as such. It measures how long each HIGH pulse lasts, and repeats that measurement every 20 ms (50 Hz). A 1.5 ms pulse means "go to the middle"; shorter pulses turn one way, longer pulses the other way.
Formula
Angle to pulse width table (50 Hz)
| Angle | SG90 (500–2500 µs) | Duty | Standard (1000–2000 µs) | Duty | Arduino write() default |
|---|---|---|---|---|---|
| 0° | 500 µs | 2.5% | 1000 µs | 5% | 544 µs |
| 45° | 1000 µs | 5% | 1250 µs | 6.25% | 1008 µs |
| 90° | 1500 µs | 7.5% | 1500 µs | 7.5% | 1472 µs |
| 135° | 2000 µs | 10% | 1750 µs | 8.75% | 1936 µs |
| 180° | 2500 µs | 12.5% | 2000 µs | 10% | 2400 µs |
The last column shows what myServo.write(angle) sends when you call attach(pin) without limits: the Arduino Servo library maps 0–180° to 544–2400 µs.
ESP32 resolution matters
At 50 Hz the period is 20 ms, and the LEDC splits it into 2^bits steps. At 8 bits one step is 78 µs, which is about 7° on an SG90 — far too coarse. Use 14 bits (works on every ESP32 chip) or 16 bits on the original ESP32. Note that the standard Arduino Servo.h library does not support the ESP32; use LEDC directly or the ESP32Servo library.
Common mistakes
- Using
analogWrite()for a servo. Arduino PWM runs at 490 or 980 Hz, which a servo cannot understand. Use the Servo library or a 50 Hz LEDC channel — see the PWM duty cycle calculator for the difference. - Forgetting the limits in
attach(). Without them,writeMicroseconds()is clamped to 544–2400 µs and an SG90 never reaches its full travel. - Driving into the end stops. A buzzing servo at 0° or 180° is pushing against its stop, getting hot and wearing its gears. Reduce the range a little.
- Losing PWM on pins 9 and 10. On an Uno the Servo library uses Timer1, so
analogWrite()no longer works on those pins. - No common ground between the servo supply and the microcontroller — the signal then has no reference and the servo jitters.
Learn the full wiring and code in our SG90 servo motor Arduino guide. Building a robot arm or a pan-tilt head? Work out the gearing with the gear ratio calculator, find project ideas in school science exhibition robotics projects, and get servos and boards in our robotics kits.





