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.
Servo.h
- Committer:
- UCSBRobotics
- Date:
- 2012-08-02
- Revision:
- 3:5357104c16a6
- Parent:
- 2:19f995979c6a
- Child:
- 7:ff85ac12e11b
File content as of revision 3:5357104c16a6:
#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 Ticker refreshTicker; Timeout servoTimeout; unsigned int pulseWidth; DigitalOut signalPin; static void refresh(); void timeout(); }; #endif // SERVO_H