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.cpp
- Revision:
- 15:753c5d6a63b3
- Child:
- 21:c2a2e7cbabdd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo_PWM/Servo_PWM.cpp Mon Oct 29 16:43:10 2012 +0000 @@ -0,0 +1,23 @@ +#include "Servo_PWM.h" +#include "mbed.h" + +Servo_PWM::Servo_PWM(PinName Pin) : ServoPin(Pin) { + ServoPin.period(0.020); + ServoPin = 0; + initialize(); // TODO: Works? +} + +void Servo_PWM::initialize() { + // initialize ESC + SetPosition(1000); // full throttle + wait(0.01); // for 0.01 secs + SetPosition(1000); // low throttle +} + +void Servo_PWM::SetPosition(int position) { + ServoPin.pulsewidth(position/1000000.0); +} + +void Servo_PWM::operator=(int position) { + SetPosition(position); +} \ No newline at end of file