pour simone

Dependencies:   MPU6050 mbed

Committer:
ThomasGS
Date:
Fri Jun 03 13:51:01 2016 +0000
Revision:
0:63c6db89607f
Child:
2:146ff0747375
1rst one

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThomasGS 0:63c6db89607f 1 #include "mbed.h"
ThomasGS 0:63c6db89607f 2 #include "mycontroller.h"
ThomasGS 0:63c6db89607f 3 #include "MPU6050.h"
ThomasGS 0:63c6db89607f 4
ThomasGS 0:63c6db89607f 5 DigitalOut myled(LED1);
ThomasGS 0:63c6db89607f 6 Serial pc(USBTX, USBRX);
ThomasGS 0:63c6db89607f 7 Ticker filter;
ThomasGS 0:63c6db89607f 8 Ticker toggler1;
ThomasGS 0:63c6db89607f 9 MPU6050 mpu6050;
ThomasGS 0:63c6db89607f 10 /*
ThomasGS 0:63c6db89607f 11 PwmOut pwm1A(PA_10);
ThomasGS 0:63c6db89607f 12 PwmOut pwm1B(PA_6);
ThomasGS 0:63c6db89607f 13 PwmOut pwm1C(PB_6);
ThomasGS 0:63c6db89607f 14 DigitalOut enable1A(PA_7);
ThomasGS 0:63c6db89607f 15 DigitalOut enable1B(PA_9);
ThomasGS 0:63c6db89607f 16 */
ThomasGS 0:63c6db89607f 17 float pitchAngle = 0;
ThomasGS 0:63c6db89607f 18 float rollAngle = 0;
ThomasGS 0:63c6db89607f 19
ThomasGS 0:63c6db89607f 20 void compFilter() {mpu6050.complementaryFilter(&pitchAngle, &rollAngle);}
ThomasGS 0:63c6db89607f 21 void toggle_led1() {myled!=myled;}
ThomasGS 0:63c6db89607f 22 void toggle_led2();
ThomasGS 0:63c6db89607f 23
ThomasGS 0:63c6db89607f 24 int main() {
ThomasGS 0:63c6db89607f 25 brushlessservo moteur;
ThomasGS 0:63c6db89607f 26 mpu6050.init();
ThomasGS 0:63c6db89607f 27 filter.attach(&compFilter, 0.005);
ThomasGS 0:63c6db89607f 28 wait(1);
ThomasGS 0:63c6db89607f 29 /*
ThomasGS 0:63c6db89607f 30 moteur.gotothetha(450);
ThomasGS 0:63c6db89607f 31 wait(1);
ThomasGS 0:63c6db89607f 32 moteur.gotothetha(0);
ThomasGS 0:63c6db89607f 33 wait(1);
ThomasGS 0:63c6db89607f 34 moteur.gotothetha(1350);
ThomasGS 0:63c6db89607f 35 moteur.gotothetha(0);
ThomasGS 0:63c6db89607f 36
ThomasGS 0:63c6db89607f 37 for(int i=0; i<1800;i+=5){
ThomasGS 0:63c6db89607f 38 moteur.gotothetha(i);
ThomasGS 0:63c6db89607f 39 wait_ms(100);
ThomasGS 0:63c6db89607f 40 }
ThomasGS 0:63c6db89607f 41 */
ThomasGS 0:63c6db89607f 42 // int32_t angle = 0;
ThomasGS 0:63c6db89607f 43
ThomasGS 0:63c6db89607f 44 while(1) {
ThomasGS 0:63c6db89607f 45 //printf("%f\n",pitchAngle);
ThomasGS 0:63c6db89607f 46 moteur.gotothetha( ((int)pitchAngle)*10 );
ThomasGS 0:63c6db89607f 47 //moteur.test();
ThomasGS 0:63c6db89607f 48 }
ThomasGS 0:63c6db89607f 49 }