Servos
Easily control your robotic movements using the Echo's dedicated servo ports.
Intro
Servos are motors that can move to precise positions and hold them steady. They're perfect for moving robot arms, steering mechanisms, camera gimbals, and any project where you need accurate positioning.
Overview
The Echo board provides 10 dedicated servo ports (labeled 0-9), allowing you to control up to 10 servos at once.
⚠️ Important Power Limitation: The combined current draw of all your servos must not exceed 10 Amperes. This is plenty for most hobby projects, but be mindful when using multiple heavy-duty servos.
init()
Initialize driver (required!)
init(freq)
Initialize with custom frequency
setServoAngle(port, angle)
Move specific servo to a specific angle
setAllZero()
Reset all servos to 0°
Getting Started
Basic Setup
Every servo project starts with these essential steps:
#include <EchoLib.h>
ServoDriver servoDriver;
void setup() {
servoDriver.init(); // CRITICAL: Always call this first!
}
void loop() {
// Your servo control code here
}🚨 Critical Note: You must call
servoDriver.init()in yoursetup()function. Skipping this step will cause crashes!
Your First Moving Servo
Let's make a servo move to 90 degrees (middle position):
The servo will move to 90 degrees and stay there. No code needed in loop() to hold the position!
API Reference
Initialization
Initializes the servo driver with default settings (60 Hz frequency). Always call this first!
init(frequency)
Initializes the servo driver with a custom frequency. Most servos work best at 50-60 Hz.
Servo Control
setServoAngle()
Moves a specific servo to the desired angle.
Parameters:
servo: Servo port number (0-9, matches the labels on your Echo board)angle: Target angle in degrees (0-180)
Examples:
setAllZero()
Instantly moves all connected servos to their 0-degree position. Great for resetting your robot to a "home" position.
Practical Examples
Sweeping Servo
Make a servo sweep back and forth continuously:
Multi-Servo Robot Arm
Control multiple servos to create a simple robot arm:
Interactive Servo Control
Control servos through the Serial Monitor:
Troubleshooting
Common Issues
Servo doesn't move:
✅ Did you call
servoDriver.init()insetup()?✅ Is the servo properly connected to the correct port?
✅ Is your power supply adequate for your servos?
Servo jitters or moves erratically:
Try different frequency:
servoDriver.init(50)instead of defaultAdd small delays between servo commands
Check for loose connections
Multiple servos don't work:
Verify total current draw is under 10A
Test servos individually first
Ensure adequate power supply
Code crashes:
Most crashes happen when
init()is not calledAlways initialize before controlling servos
Tips for Success
Always initialize first: Call
servoDriver.init()before any servo commandsStart simple: Test one servo before adding multiple servos
Use delays: Add small delays between movements for smooth motion
Check connections: Ensure servos are firmly connected to the correct ports
Monitor power: Keep total current under 10A limit
Test angles: Servo range is 0-180 degrees - values outside this range are automatically clamped
Last updated