A simple library for driving RC servos without using the mbed's PWM functions. This allows the mbed to drive as many servos as there are DigitalOut pins, and additionally allows for the PWM functions to be used at a different frequency than the 50Hz used for servos.
Diff: Servo.cpp
- Revision:
- 6:6af888a91e23
- Parent:
- 5:94cdc85bf1ae
- Parent:
- 4:373219702af9
- Child:
- 7:ff85ac12e11b
--- a/Servo.cpp Fri Aug 03 05:21:59 2012 +0000 +++ b/Servo.cpp Fri Aug 03 05:31:40 2012 +0000 @@ -22,7 +22,7 @@ if (numServos == 0) { - // Start the timeout that refreshes all servos + // Start the ticker that refreshes all servos refreshTicker.attach_us(&Servo::refresh, period); } @@ -61,10 +61,7 @@ void Servo::refresh() -{ - // Restart the refresh timeout - refreshTicker.attach_us(&Servo::refresh, period); - +{ // Start all of the individual servo width timeouts and write a logical 1 to their signal pins for (int i = 0; i < numServos; i++) {