User Manual

Reference
C++ and Arduino methods are shown in red.
C functions are shown in green.
static unsigned char OrangutanServos::start(const unsigned char servo_pins[], unsigned char
num_pins)
unsigned char servos_start(const unsigned char servo_pins [], unsigned char num_pins)
Configures the AVR’s Timer 1 module to generate pulses for up to 8 servos. The num_pins
parameter should be the length of the servo_pins array. A nonzero return value indicates that the
needed memory could not be allocated.
The servo_pins parameter should be the RAM address of an array of AVR I/O pin numbers defined
using the IO_* keywords provided by the library (e.g. IO_D1 for a servo output on pin PD1).
On the Orangutan SVP: this function takes an array of AVR pins that you have wired to the demux
selection pins. The length of the array should be 0–3. The number of servos you can control is
2
num_pins
. The servo pulses are generated on pin PD5, which is a hardware PWM output connected
to the input of the demux, and servos should be connected to demux (servo port) outputs 0
2
num_pins
on the SVP. See the “Servo Demultiplexer” portion of Section 4 of the Orangutan SVP
user’s guide for more information.
On the other Orangutans: this function takes an array of AVR pins that you have connected to the
signal pins on your servos. The length of the array should be 0–8. Each pin controls one servo.
This function was previously called servos_init(). To maintain compatibility with older versions of
the library, servos_init() still exists, but use of servos_start() is encouraged.
Example
static unsigned char OrangutanServos::start(const unsigned char servo_pins[], unsigned char
num_pins, const unsigned char servo_pins_b[], unsigned char num_pins_b)
unsigned char servos_start_extended(const unsigned char servo_pins[], unsigned char
num_pins, const unsigned char servo_pins_b[], unsigned char num_pins_b)
Configures the AVR’s Timer 1 module to generate pulses for up to 16 servos. A nonzero return value
indicates that the needed memory could not be allocated. The servo_pins and num_pins parameters
serve the same purpose here as they do in the function above. The num_pins_b parameter should
be the length of the servo_pins_b array. The servo_pins_b parameter should be the RAM address
1
2
3
4
5
// Orangutan SVP: configure PD0 and PD1 to be demux inputs SA and SB,
// which generates servo pulses on demux pins 0 - 3
// All else: configure for two servo outputs on pins PD0 and PD1
servos_start((unsigned char[]) {IO_D0, IO_D1}, 2);
// C++: OrangutanServos::start((unsigned char[]) {IO_D0, IO_D1}, 2);
?
Pololu AVR Library Command Reference © 2001–2019 Pololu Corporation
11. Orangutan Servos Page 51 of 77