Home > Industry Insights >Servo
TECHNICAL SUPPORT

Product Support

How to Control the Rotation of a Servo Pan-Tilt System: A Step-by-Step Technical Guide

Published 2026-04-22

This guide provides a complete, actionable method for controlling the rotation of aservo-based pan-tilt system. You will learn the core principle (PWM signal control), hardware connection steps, and programming logic to achieve precise, independent pan (horizontal) and tilt (vertical) rotation. All instructions are based on industry‑standardservocontrol specifications and verified by common open‑source electronics platforms.

01Core Principle: PWM Signal Controls Rotation Angle

Every standardservoin a pan‑tilt system rotates to a specific angle based on the width of a pulse in a Pulse Width Modulation (PWM) signal. The control parameters are fixed:

Signal frequency: 50 Hz (period = 20 milliseconds)

Pulse width rangefor full rotation (typical 0° to 180°):

0° → pulse width0.5 ms(duty cycle 2.5%)

90° → pulse width1.5 ms(duty cycle 7.5%)

180° → pulse width2.5 ms(duty cycle 12.5%)

> Source: Standard specification for hobby servo motors (Futaba, Hitec, and all compatible manufacturers).

Thus, to control rotation, you must generate a continuous 50 Hz signal and change the pulse width to the desired angle’s corresponding value.

02Hardware Connection (No Brand Names)

A pan‑tilt system typically contains two servos: one for pan (horizontal rotation) and one for tilt (vertical rotation). Connect them to a common microcontroller or servo driver board as follows:

Servo wire Color (standard) Connection
Power (VCC) Red +5V DC power supply (shared)
Ground (GND) Brown or Black Common ground
Signal (PWM) Orange or Yellow Separate digital I/O pins (e.g., Pin 9 for pan, Pin 10 for tilt)

Critical note: Use a separate 5V/2A (minimum) power supply for the servos. Do not power them directly from the microcontroller’s 5V pin – this causes erratic rotation or resetting.

03Software Control: Step‑by‑Step for Any Platform

The logic below works on any system that can generate software‑defined PWM (Arduino‑like, Raspberry Pi, ESP32, STM32). We use pseudo‑code for universal application.

Step 1: Define the mapping function

Convert an angle (0° to 180°) to the required pulse width in microseconds:

pulseWidth(angle) = 500 + (angle * (2500 - 500) / 180)

At 0° → 500 µs (0.5 ms)

At 90° → 1500 µs (1.5 ms)

At 180° → 2500 µs (2.5 ms)

Step 2: Initialize PWM on two pins

旋转云台怎么用_舵机云台怎么控制_舵机云台怎么控制旋转

Set PWM frequency to 50 Hz. In a typical microcontroller environment:

pinMode(panPin, OUTPUT)
pinMode(tiltPin, OUTPUT)
setupPWM(panPin, 50Hz)
setupPWM(tiltPin, 50Hz)

Step 3: Write rotation commands

To rotate pan to 120° and tilt to 45°:

writeMicroseconds(panPin, pulseWidth(120))   // 120° → 1833 µs
writeMicroseconds(tiltPin, pulseWidth(45))   // 45°  → 1111 µs
delay(300)   // Allow servos to reach position (typical 0.2-0.5 sec)

Step 4: Continuous motion (sweeping)

For a smooth scanning motion (common in camera tracking or obstacle detection):

for angle = 0 to 180 step 1:
    writeMicroseconds(panPin, pulseWidth(angle))
    delay(15)   // 15 ms gives smooth motion at 50 Hz cycle

04Real‑World Example: Joystick Control

A common case is using an analog joystick to manually control pan‑tilt rotation. Connect the joystick’s X‑axis to an analog input (pan control) and Y‑axis to another analog input (tilt control). The microcontroller reads the joystick value (0‑1023) and maps it to 0‑180°:

panAngle = map(joystickX, 0, 1023, 0, 180)
tiltAngle = map(joystickY, 0, 1023, 0, 180)
writeMicroseconds(panPin, pulseWidth(panAngle))
writeMicroseconds(tiltPin, pulseWidth(tiltAngle))
delay(20)

This produces immediate, proportional rotation in both axes – exactly how most manual camera mounts or robot head controls work.

05Troubleshooting Common Rotation Problems

Symptom Most Likely Cause Verified Fix
Servo does not rotate at all Missing power supply or wrong pin assignment Connect external 5V/2A supply; verify signal pin is PWM‑capable
Rotation is jittery or twitching Insufficient power or electrical noise Add a 1000µF electrolytic capacitor across VCC and GND near servos
Servo rotates only to extreme ends (0° or 180°) Wrong pulse width range Confirm your pulseWidth() function outputs between 500 and 2500 µs
Rotation is reversed (90° moves to 0°) Signal polarity inverted Swap the two signal wires (if using digital servo) or invert the mapping: angle = 180 - angle
Pan and tilt interfere (both move together) Shared signal line or software bug Use two separate digital pins; never writeMicroseconds() to both in the same instruction without delay

06Core Principle Restated

To control rotation of a servo pan‑tilt system, you must generate a continuous 50 Hz PWM signal and vary the pulse width between 0.5 ms (0°) and 2.5 ms (180°). Independent pan and tilt motion requires two separate PWM pins and a power supply that delivers at least 1A per servo.

07Actionable Next Steps

1. Start with a single servo – Connect one servo, test the pulseWidth(angle) function by slowly sweeping from 0° to 180°. Verify rotation range.

2. Add the second servo – Once the first works perfectly, connect the tilt servo to another pin and repeat the test.

3. Implement your control method – Choose between joystick, pre‑programmed sweep, or external sensor input (e.g., ultrasonic for auto‑panning).

4. Always use external power – This single practice eliminates 90% of rotation failures.

By following this guide, you can achieve precise, repeatable rotation control for any standard servo‑based pan‑tilt system without relying on proprietary libraries or branded hardware.

Update Time:2026-04-22

Powering The Future

Contact Kpower's product specialist to recommend suitable motor or gearbox for your product.

Mail to Kpower
Submit Inquiry
+86 0769 8399 3238
 
kpowerMap