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.
Servo Class Reference
Class to control a servo on any pin, without using pwm. More...
#include <Servo.h>
Public Member Functions | |
Servo (PinName Pin) | |
Create a new Servo object on any mbed pin. | |
void | SetPosition (int NewPos) |
Change the position of the servo. | |
void | Enable (int StartPos, int Period) |
Enable the servo. | |
void | Disable () |
Disable the servo. |
Detailed Description
Class to control a servo on any pin, without using pwm.
Example:
// Keep sweeping servo from left to right #include "mbed.h" #include "Servo.h" Servo Servo1(p20); Servo1.Enable(1500,20000); while(1) { for (int pos = 1000; pos < 2000; pos += 25) { Servo1.SetPosition(pos); thread_sleep_for(20); } for (int pos = 2000; pos > 1000; pos -= 25) { Servo1.SetPosition(pos); thread_sleep_for(20); } }
Definition at line 54 of file Servo.h.
Constructor & Destructor Documentation
Servo | ( | PinName | Pin ) |
Member Function Documentation
void Disable | ( | ) |
void Enable | ( | int | StartPos, |
int | Period | ||
) |
Generated on Thu Jul 14 2022 22:15:28 by
