|
STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
|
← STM32duino documentation
|
Servo motor controller. More...
#include <Servo.h>
Public Member Functions | |
| Servo () | |
| Create a servo instance and assign it a channel index. | |
| uint8_t | attach (pin_size_t pin, int value=DEFAULT_PULSE_WIDTH) |
| Attach the servo to a pin, using the default min and max pulse widths. | |
| uint8_t | attach (pin_size_t pin, int min, int max, int value=DEFAULT_PULSE_WIDTH) |
| Attach the servo to a pin, with custom min and max pulse widths. | |
| void | detach () |
| Stop the servo from pulsing its pin. | |
| void | write (int value) |
| Set the servo position. | |
| void | writeMicroseconds (int value) |
| Set the servo pulse width. | |
| int | read () |
| Get the last written position. | |
| int | readMicroseconds () |
| Get the last written pulse width. | |
| bool | attached () |
| Check if the servo is attached. | |
Servo motor controller.
Each instance drives one servo on a pin, using a shared 16 bit timer.
| Servo::Servo | ( | ) |
Create a servo instance and assign it a channel index.
| uint8_t Servo::attach | ( | pin_size_t | pin, |
| int | min, | ||
| int | max, | ||
| int | value = DEFAULT_PULSE_WIDTH |
||
| ) |
Attach the servo to a pin, with custom min and max pulse widths.
The pin is set as output and the servo is moved to the initial value. The min and max values are used to limit the writes and have a resolution of 4 microseconds.
| pin | Pin number to attach the servo to. |
| min | Pulse width in microseconds for 0 degrees (MIN_PULSE_WIDTH by default with the 2 parameters version). |
| max | Pulse width in microseconds for 180 degrees (MAX_PULSE_WIDTH by default with the 2 parameters version). |
| value | Initial value, as an angle in degrees or a pulse width in microseconds. Default: DEFAULT_PULSE_WIDTH. |
| uint8_t Servo::attach | ( | pin_size_t | pin, |
| int | value = DEFAULT_PULSE_WIDTH |
||
| ) |
Attach the servo to a pin, using the default min and max pulse widths.
The pin is set as output and the servo is moved to the initial value.
| pin | Pin number to attach the servo to. |
| value | Initial value, as an angle in degrees or a pulse width in microseconds. Default: DEFAULT_PULSE_WIDTH. |
| bool Servo::attached | ( | ) |
Check if the servo is attached.
| void Servo::detach | ( | ) |
Stop the servo from pulsing its pin.
The timer is paused when no servo is active.
| int Servo::read | ( | ) |
Get the last written position.
| int Servo::readMicroseconds | ( | ) |
Get the last written pulse width.
| void Servo::write | ( | int | value | ) |
Set the servo position.
A value less than MIN_PULSE_WIDTH is treated as an angle (limited to 0-180), otherwise it is treated as a pulse width in microseconds (see writeMicroseconds()).
| value | Angle in degrees (0 to 180) or pulse width in microseconds. |
| void Servo::writeMicroseconds | ( | int | value | ) |
Set the servo pulse width.
The value is clamped to the min and max pulse widths of this servo.
| value | Pulse width in microseconds. |