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:
- 21:c2a2e7cbabdd
- Parent:
- 15:753c5d6a63b3
- Child:
- 22:d301b455a1ad
--- a/Servo_PWM/Servo_PWM.cpp Mon Nov 05 09:19:01 2012 +0000 +++ b/Servo_PWM/Servo_PWM.cpp Sat Nov 17 11:49:21 2012 +0000 @@ -4,18 +4,16 @@ Servo_PWM::Servo_PWM(PinName Pin) : ServoPin(Pin) { ServoPin.period(0.020); ServoPin = 0; - initialize(); // TODO: Works? + initialize(); } void Servo_PWM::initialize() { // initialize ESC - SetPosition(1000); // full throttle - wait(0.01); // for 0.01 secs - SetPosition(1000); // low throttle + SetPosition(0); // zero throttle } void Servo_PWM::SetPosition(int position) { - ServoPin.pulsewidth(position/1000000.0); + ServoPin.pulsewidth((position+1000)/1000000.0); } void Servo_PWM::operator=(int position) {