servoding

Dependencies:   mbed Servo

main.cpp

Committer:
S1lverEagle
Date:
2015-10-27
Revision:
2:9bb7e571b55f
Parent:
1:c6e4257722b9

File content as of revision 2:9bb7e571b55f:

#include "mbed.h"
#include "math.h"
#include "Servo.h" 

//servo ranges from .6ms to 2.7ms duty cycle in 20ms pwm period

Servo servoPwm(D5);

double theta1;
double theta2;
double theta3;

Ticker servo;
 
     void servo_control()
{
     theta3 = 180 - theta1 - theta2;
     servoPwm.SetPosition = (2100/180)*theta3 + 600;
     }

int main() 
{   
      servoPwm.Enable(1650,20000);
        servo.attach(&servo_control,0,02);
        while(true){}
        }