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:
2:19f995979c6a
Child:
3:5357104c16a6
diff -r 4d239acffd14 -r 19f995979c6a Servo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.h	Wed Aug 01 22:28:33 2012 +0000
@@ -0,0 +1,30 @@
+#ifndef SERVO_H
+#define SERVO_H
+
+#include "mbed.h"
+
+
+
+class Servo
+{
+public:
+    Servo(PinName pin, unsigned int width = 1500);
+    void write(int width);
+    int read();
+    void operator=(int width);
+    operator int();
+    
+protected:
+    static unsigned int numServos;
+    static Servo *servos[];
+    static const unsigned int period = 20000;
+    static Timeout refreshTimeout;
+    Timeout servoTimeout;
+    unsigned int pulseWidth;
+    DigitalOut signalPin;
+    
+    static void refresh();
+    void timeout();
+};
+
+#endif // SERVO_H
\ No newline at end of file