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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Servo_PWM.cpp Source File

Servo_PWM.cpp

00001 #include "Servo_PWM.h"
00002 #include "mbed.h"
00003 
00004 Servo_PWM::Servo_PWM(PinName Pin, int frequency) : ServoPin(Pin) {
00005     SetFrequency(frequency);
00006     ServoPin = 0;
00007     initialize();
00008 }
00009 
00010 void Servo_PWM::SetFrequency(int frequency) {
00011     ServoPin.period(1.0/frequency);
00012 }
00013 
00014 void Servo_PWM::initialize() {
00015     // initialize ESC
00016     SetPosition(0);  // zero throttle
00017 }
00018 
00019 void Servo_PWM::SetPosition(int position) {
00020     ServoPin.pulsewidth_us(position+1000);
00021 }
00022 
00023 void Servo_PWM::operator=(int position) {
00024     SetPosition(position);
00025 }