Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Brute_TS_Controller_2018_11
Servo Class Reference
Servo control class, based on a PwmOut. More...
#include <Servo.h>
Public Member Functions | |
| Servo (PinName pin) | |
| Create a servo object connected to the specified PwmOut pin. | |
| void | write (double percent) |
| Set the servo position, normalised to it's full range. | |
| double | read () |
| Read the servo motors current position. | |
| void | position (double degrees) |
| Set the servo position. | |
| void | calibrate (double range=0.0005, double degrees=45.0) |
| Allows calibration of the range and angles for a particular servo. | |
| Servo & | operator= (double percent) |
| Shorthand for the write and read functions. | |
Detailed Description
Servo control class, based on a PwmOut.
Example:
// Continuously sweep the servo through it's full range #include "mbed.h" #include "Servo.h" Servo myservo(p21); int main() { while(1) { for(int i=0; i<100; i++) { myservo = i/100.0; wait(0.01); } for(int i=100; i>0; i--) { myservo = i/100.0; wait(0.01); } } }
Definition at line 52 of file Servo.h.
Constructor & Destructor Documentation
| Servo | ( | PinName | pin ) |
Member Function Documentation
| void calibrate | ( | double | range = 0.0005, |
| double | degrees = 45.0 |
||
| ) |
| Servo & operator= | ( | double | percent ) |
| void position | ( | double | degrees ) |
| double read | ( | ) |
Generated on Wed Jul 13 2022 19:35:56 by
1.7.2