User Manual

3.i. Orangutan Servo Control Functions
Overview
This section of the library provides commands for generating digital pulses to control servos.
Complete documentation of these functions can be found in Section 11 of the Pololu AVR Library
Command Reference [https://www.pololu.com/docs/0J18].
Note: The OrangutanServos and OrangutanBuzzer libraries both use Timer 1, so they
will conflict with each other and any other code that relies on or reconfigures
Timer 1.
Servos
A servo motor (also called hobby servo or RC servo) is a device containing a motor that you can
command to turn to a specific location. To control a servo, you must connect its three wires properly.
The black wire is ground, and should be connected to the ground line of your Orangutan. The red line
is power, and should be connected to power supply with a voltage that is within the operating range
of your servo, and that is capable of supplying all the current that your servo might draw. The white
line is signal, and should be connected to a pin that generates servo pulses, such as an I/O line on
the Orangutan. The Orangutan I/O header blocks make it easy to connect your servos, because each
column of the block contains ground, power, and an I/O line in the correct order.
To make your servo move, you must output a high pulse to the signal line every 20 ms. The pulse
width (also called pulse length or pulse duration) determines which position the servo will move to.
Thus, every pulse width (typically measured in microseconds) corresponds to some angle (typically
measured in degrees) of the servo’s output shaft. Typical servos have a limited range of motion, and
this entire range of motion can be reached with pulse widths between 1 ms and 2 ms.
Take care when choosing pulse widths, because some servos are capable of breaking themselves if
they are commanded to move to a position outside their range of motion. To start off, you can send
pulse widths of 1.5 ms and then slowly change the pulse width until you discover its upper and lower
125
126
127
128
129
130
131
132
133
134
// Wait for the user to release the button. While the processor is
// waiting, the OrangutanSerial library will take care of receiving
// bytes using the serial reception interrupt. But if enough bytes
// arrive during this period to fill up the receive_buffer, then the
// older bytes will be lost and we won't know exactly how many bytes
// have been received.
wait_for_button_release(MIDDLE_BUTTON);
}
}
}
Pololu AVR C/C++ Library User’s Guide © 2001–2019 Pololu Corporation
3. Functional Overview and Example programs Page 34 of 56