Arduino

ServoAPI DOCUMENTATION

Control many servos without delay or interrupts.

See Example  Public Methods  Release Notes
Overview

Control many servos at once without delay or interrupts while applying rotation adjustments with PWM/PPM. Quickly calibrate each servo in the constructor() by setting the min and max pulse length (in microseconds), then make real-time adjustments to the rotation with moveToDegrees().

Connect as many servos as the number of digital pins available on your Arduino. This library is very fast and has a small, lightweight code footprint.

Example Wiring
  1. Connect the servo red wire to the Arduino +5v pin (or use external power)
  2. Connect the servo brown or black wire to the Arduino ground pin
  3. Connect the servo orange or yellow wire to the Arduino digital pin 2
  4. Load the Example Sketch onto the Arduino
  5. Watch the servo adjust to the desired position

A servo wired to an Arduino Micro digital pin 2.

Example SketchArduinoC++
Public Methods

You must continuously call update() inside of loop() in order to use theReal-Time methods tagged below.

RBD::Servo constructor(pin, pulse_min, pulse_max)

Pass in an integer for the digital Arduino pin that is connected to the servo movement control wire (orange or yellow).

For the second and third parameters; pass in unsigned longs for the hardware specified microsecond pulse min and max times, which determine the time limits for calculating the length of the orientation pulse (typically between 1000-2000 microseconds, or 1-2 milliseconds).

EXAMPLE SKETCH
servo
.setPulseInterval(value)

Provide an unsigned long to set the amount of time between each orientation pulse. The default is 20ms and is set automatically in the constructor().

EXAMPLE SKETCH
servo
.setDegreesOfRotation(value)

Provide an integer to set the maximum number of degrees of rotation the servo can handle. The default is 180 degrees and is set automatically in the constructor().

EXAMPLE SKETCH
servo
.update()Update

Keep processing and applying servo movements to the motor. This must be called continuously within loop() in order to use moveToDegrees().

EXAMPLE SKETCH
servo
.moveToDegrees(value)Real-Time

Provide an integer and the servo will move to the specified position in degrees. This can be called inside of setup() or also at run-time inside of loop().

EXAMPLE SKETCH