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:
- 29:8b7362a2ee14
- Parent:
- 22:d301b455a1ad
diff -r ba6ca9f4def4 -r 8b7362a2ee14 Servo_PWM/Servo_PWM.cpp --- a/Servo_PWM/Servo_PWM.cpp Sat Dec 01 07:13:04 2012 +0000 +++ b/Servo_PWM/Servo_PWM.cpp Sat Dec 15 08:42:36 2012 +0000 @@ -1,12 +1,16 @@ #include "Servo_PWM.h" #include "mbed.h" -Servo_PWM::Servo_PWM(PinName Pin) : ServoPin(Pin) { - ServoPin.period(0.020); +Servo_PWM::Servo_PWM(PinName Pin, int frequency) : ServoPin(Pin) { + SetFrequency(frequency); ServoPin = 0; initialize(); } +void Servo_PWM::SetFrequency(int frequency) { + ServoPin.period(1.0/frequency); +} + void Servo_PWM::initialize() { // initialize ESC SetPosition(0); // zero throttle