![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
2017能代宇宙イベント開放用プログラム(kobayashi)
Dependencies: mbed MS5607 MPU6050
Diff: main.cpp
- Revision:
- 4:a44c7a8adaeb
- Parent:
- 3:507d05fb5cd8
- Child:
- 5:e5c45611bf43
--- a/main.cpp Sun Aug 06 07:00:12 2017 +0000 +++ b/main.cpp Sun Aug 06 09:48:17 2017 +0000 @@ -5,7 +5,7 @@ #define START_kasokudo 0 #define START_koudo 0 -#define P_openkoudo 0.5 +#define P_openkoudo 150 #define SETUP 0 #define LAUNCH 1 #define RISE 2 @@ -13,12 +13,13 @@ #define DROP2 4 #define LAND 5 +Degitalout +Serial pc(USBTX,USBRX); MS5607I2C ms(p9,p10,false); MPU6050 mpu(p9,p10); DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3);//後で削除// -DigitalOut myled4(LED4); PwmOut servo1(p23); PwmOut servo2(p24); PwmOut servo3(p25); @@ -31,6 +32,17 @@ Timer Time; float LAUNCHtime,RISEtime,DROP1time; +void _judge(); +float _mannaka + +int main(){ + Timer start(); + Time.start(); + tic.attach(&_judge,0.1); + while(1); + return 0; +} + void _judge(){ switch(Phase){ case SETUP: @@ -58,20 +70,18 @@ case RISE: myled2=0; float alt_RISE = ms.getAltitude(); - if(max < alt_RISE){ + if(max < alt_RISE+0.5){ max = alt_RISE; - }else if(max+10 >= alt_RISE){ - max = alt_RISE; + }else if(max+0.5 > alt_RISE){ count_RISE++; RISEtime = Time.read(); } - if(Time.read() >= RISEtime + 0.5){ + if(Time.read() >= RISEtime + 1.0){ count_RISE = 0; } - if(count_RISE==5);{ + if(count_RISE==5){ servo1.pulsewidth(0.0015); servo2.pulsewidth(0.0015); - wait(2.0); myled2 = 1; Phase=DROP1; } @@ -80,12 +90,12 @@ case DROP1: myled3=0; float alt_DROP1 = ms.getAltitude(); - if(alt_DROP1 - START_koudo < P_openkoudo){ + if((alt_DROP1 - START_koudo) < P_openkoudo){ count_DROP1++; } if(Time.read() <= DROP1time + 0.5){ count_DROP1 = 0; - } + } if(count_DROP1==5){ servo3.pulsewidth(0.0015); wait(2.0); @@ -107,10 +117,5 @@ } } -int main(){ - Timer start(); - Time.start(); - tic.attach(&_judge,0.1); - while(1); - return 0; -} \ No newline at end of file +float _mannaka{ + \ No newline at end of file