NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.
Diff: Servo_PWM/Servo_PWM.h
- Revision:
- 15:753c5d6a63b3
- Child:
- 26:96a072233d7a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo_PWM/Servo_PWM.h Mon Oct 29 16:43:10 2012 +0000 @@ -0,0 +1,59 @@ +// by MaEtUgR + +#ifndef SERVO_PWM_H +#define SERVO_PWM_H + +#include "mbed.h" + +/** Class to control a servo on any pin, without using pwm + * + * Example: + * @code + * // Keep sweeping servo from left to right + * #include "mbed.h" + * #include "Servo.h" + * + * Servo Servo1(p20); + * + * Servo1.Enable(1500,20000); + * + * while(1) { + * for (int pos = 1000; pos < 2000; pos += 25) { + * Servo1.SetPosition(pos); + * wait_ms(20); + * } + * for (int pos = 2000; pos > 1000; pos -= 25) { + * Servo1.SetPosition(pos); + * wait_ms(20); + * } + * } + * @endcode + */ + +class Servo_PWM { + +public: + /** Create a new Servo object on any mbed pin + * + * @param Pin Pin on mbed to connect servo to + */ + Servo_PWM(PinName Pin); + + /** Change the position of the servo. Position in us + * + * @param NewPos The new value of the servos position (us) + */ + void SetPosition(int position); + + //operator for confortable positioning + void operator=(int position); + + // initialize ESC + void initialize(); + +private: + PwmOut ServoPin; + +}; + +#endif \ No newline at end of file