⚡
usefultools.dev
SRV

Arduino Servo Calculator (Angle to Pulse Width)

NEW

Arduino servo calculator: convert servo angle to pulse width and back, get the 50 Hz duty cycle and PCA9685 tick count, plus Servo.h code.

Runs 100% in your browser — your input is never uploaded or stored on our servers.

Pulse width
1472 µs
Duty @ 50 Hz
7.36 %
PCA9685 ticks
302 / 4096
Servo.write() sends
1472 µs

PCA9685: prescale 121 → actual 50.029 Hz, 1 tick = 4.88 µs. Servo.write() takes an integer angle 0–180, maps it with integer map() and so can be up to one step off the ideal pulse.

anglepulse µswrite()duty %ticks
0°5445442.72111
30°853.338534.267175
60°1162.6711625.813238
90°147214727.36302
120°1781.3317818.907365
150°2090.67209010.453428
180°2400240012492

Arduino code

// ── Option 1: Servo library on a PWM-capable pin ──
#include <Servo.h>
Servo servo;

void setup() {
  servo.attach(9, 544, 2400);   // pin, min µs, max µs
  servo.writeMicroseconds(1472);            // 90°
  // or: servo.write(90);  (write() maps 0..180 onto 544..2400 µs)
}
void loop() {}

// ── Option 2: PCA9685 16-channel driver (Adafruit_PWMServoDriver) ──
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm;   // I2C address 0x40

void setup() {
  pwm.begin();
  pwm.setOscillatorFrequency(25000000);   // trim to your board, often 25–27 MHz
  pwm.setPWMFreq(50);
  pwm.setPWM(0, 0, 302);   // 1472 µs ≈ 302 ticks
}
void loop() {}

Power servos from a separate 5–6 V supply with a common ground, not from the Arduino 5 V pin — a stalled servo can draw over 1 A. Check your servo's datasheet for its safe pulse range before driving it to the end stops.

⚡

Quick Examples

Typical inputs and the results this tool produces.

Servo.h
90°, Servo.h 544–2400 µs
1472 µs · 7.36 % · 302 ticks
Standard RC
45°, 1000–2000 µs
1250 µs · 6.25 % · 256 ticks
Pulse → angle
1500 µs, 1000–2000 µs
90° · 7.5 % · 307 ticks
PCA9685
PCA9685 at 50 Hz, 25 MHz
prescale 121, 4.88 µs/tick
📖

Overview

Hobby servos are positioned by the width of a pulse repeated about 50 times per second: roughly 1 ms at one end, 1.5 ms in the middle and 2 ms at the other end. The Arduino Servo library uses a wider default of 544–2400 µs for 0–180°, while many servos only accept 1000–2000 µs, and the PCA9685 driver board needs the pulse expressed as a 12-bit tick count instead of microseconds.

This Arduino servo calculator converts an angle to a pulse width (or a pulse width to an angle) for any range, shows the duty cycle at your frame rate, the value Servo.write() really sends after its integer map(), and the PCA9685 prescale, real output frequency and tick count. A table covers the whole travel and the generated sketch works with both Servo.h and Adafruit_PWMServoDriver. All calculations run in your browser.

Why use this tool?

  • Servo.h, standard RC and custom pulse ranges
  • PCA9685 prescale and tick values without guesswork
  • Shows the integer rounding of Servo.write()
  • Angle table for the full servo travel
  • Free, offline-capable and private
⭐

Features

🎯

Angle ↔ pulse width

Linear conversion between degrees and microseconds for 180°, 270° or any travel.

📊

Duty cycle

Duty cycle in percent at 50 Hz or any frame rate you enter.

🧮

PCA9685 ticks

Prescale, actual frequency, µs per tick and setPWM() off value with a trimmable oscillator.

🔍

Servo.write() check

Reproduces the library’s integer map() so you see the pulse it really outputs.

📋

Travel table

Pulse, duty and ticks for every step from 0° to full travel.

🧩

Code snippet

Copy Servo.h and Adafruit PCA9685 code with your numbers filled in.

🛠️

How to Use

1

Pick the pulse range

Choose Servo.h default, standard RC, wide or enter custom min/max microseconds.

2

Enter angle or pulse

Switch between Angle → pulse and Pulse → angle and type the value.

3

Adjust PWM settings

Set the frame rate and, for PCA9685 boards, the oscillator frequency.

4

Copy the code

Read the results and table, then copy the generated sketch.

🤔

Frequently Asked Questions