Dependencies: MPU6050 MS5607 mbed
main.cpp
- Committer:
- YujiTakbuo
- Date:
- 2017-07-31
- Revision:
- 0:e527984bccd1
- Child:
- 1:570e3c6fd4bb
File content as of revision 0:e527984bccd1:
/* alt →altitude pres →pressure acc →acceleration */ //todo 単位系どうなってるの? #include "mbed.h" #include "math.h" #include "MPU6050.h" #include "MS5607I2C.h" //todo defineの整理 #define ALT_TOP 100 #define ALT_LEAFING 300 #define ACC 4*9.8 #define COUNT 5 MPU6050 mpu(p9,p10); //tx,rx MS5607I2C ms(p9,p10,false); //tx, rx, csピンがGND DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); DigitalOut myled4(LED4); float alt=ms.getAltitude(); float acc[3]; float acc_total; float time_alt; float time_acc; int cnt_alt=0; int cnt_acc; //todo 変数の追加 Timer timer; void judge_top(){ while(1){ if(ALT_TOP>=alt){ cnt_alt++; } if(timer.read()>0.5){ cnt_alt=0; } if(cnt_alt>=COUNT){ myled1=1; //open the servos }else{ myled1=0; } } } int main(){ while(1){ judge_top(); } }