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.

Revision:
8:131785ed96fb
Parent:
7:ff85ac12e11b
Child:
9:6bfea9af4dcb
--- a/Servo.cpp	Thu Aug 30 03:36:03 2012 +0000
+++ b/Servo.cpp	Wed Oct 03 07:28:03 2012 +0000
@@ -68,8 +68,11 @@
     // Start all of the individual servo width timeouts and write a logical 1 to their signal pins
     for (int i = 0; i < numServos; i++)
     {
-        servos[i]->servoTimeout.attach_us(servos[i], &Servo::timeout, servos[i]->pulseWidth);
-        Servo::servos[i]->signalPin.write(1);
+        if (servos[i]->pulseWidth > 0)
+        {
+            servos[i]->servoTimeout.attach_us(servos[i], &Servo::timeout, servos[i]->pulseWidth);
+            Servo::servos[i]->signalPin.write(1);
+        }
     }
 }