#include <Servo.h>
Public Member Functions | |
void | calibrate (float range=0.0005, float degrees=45.0) |
operator float () | |
Servo & | operator= (float percent) |
Servo & | operator= (Servo &rhs) |
void | position (float degrees) |
float | read () |
Servo (PinName pin) | |
void | write (float percent) |
Protected Attributes | |
float | _degrees |
float | _p |
PwmOut | _pwm |
float | _range |
Servo control class, based on a PwmOut
Example:
Servo::Servo | ( | PinName | pin | ) |
Create a servo object connected to the specified PwmOut pin
pin | PwmOut pin to connect to |
void Servo::calibrate | ( | float | range = 0.0005 , |
float | degrees = 45.0 |
||
) |
Allows calibration of the range and angles for a particular servo
range | Pulsewidth range from center (1.5ms) to maximum/minimum position in seconds |
degrees | Angle from centre to maximum/minimum position in degrees |
Servo::operator float | ( | ) |
Servo& Servo::operator= | ( | float | percent | ) |
Shorthand for the write and read functions
void Servo::position | ( | float | degrees | ) |
Set the servo position
degrees | Servo position in degrees |
float Servo::read | ( | ) |
Read the servo motors current position
returns | A normalised number 0.0-1.0 representing the full range. |
void Servo::write | ( | float | percent | ) |
Set the servo position, normalised to it's full range
percent | A normalised number 0.0-1.0 to represent the full range. |
float Servo::_degrees [protected] |
PwmOut Servo::_pwm [protected] |
float Servo::_range [protected] |