Servo without PWM
A library for controlling servo's on any pin of the mbed, without using the PWM pins.
Example¶
Import program
00001 // Keep sweeping servo from left to right 00002 #include "mbed.h" 00003 #include "Servo.h" 00004 00005 Servo Servo1(p20); 00006 00007 int main() { 00008 Servo1.Enable(1000,20000); 00009 while(1) { 00010 for (int pos = 1000; pos < 2000; pos += 25) { 00011 Servo1.SetPosition(pos); 00012 wait_ms(20); 00013 } 00014 for (int pos = 2000; pos > 1000; pos -= 25) { 00015 Servo1.SetPosition(pos); 00016 wait_ms(20); 00017 } 00018 } 00019 }
Library¶
Import libraryServo
A servo library for controlling servos without using PWM. Can be used on any pin.
Import library
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.
|
This library is used to control standard R/C servo motors without using a PWM pin. It can be used on any mbed pin.
Details¶
The signal wire of the servo can be connected to every mbed pin.
The library is uses Ticker and Timout, not PwmOut.