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.

Dependencies:   mbed MODI2C

Servo_PWM/Servo_PWM.cpp

Committer:
maetugr
Date:
2012-12-15
Revision:
29:8b7362a2ee14
Parent:
22:d301b455a1ad

File content as of revision 29:8b7362a2ee14:

#include "Servo_PWM.h"
#include "mbed.h"

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
}

void Servo_PWM::SetPosition(int position) {
    ServoPin.pulsewidth_us(position+1000);
}

void Servo_PWM::operator=(int position) {
    SetPosition(position);
}