2017能代宇宙イベント開放用プログラム(kobayashi)

Dependencies:   mbed MS5607 MPU6050

Committer:
nene_kobayashi
Date:
Sat Aug 05 13:44:05 2017 +0000
Revision:
2:3a7c38279b0b
Parent:
1:fa1980f9b2d0
Child:
3:507d05fb5cd8
???????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nene_kobayashi 0:027a3ffb7500 1 #include "mbed.h"
nene_kobayashi 1:fa1980f9b2d0 2 #include "MS5607I2C.h"
nene_kobayashi 0:027a3ffb7500 3
nene_kobayashi 2:3a7c38279b0b 4 #define RISE 0
nene_kobayashi 2:3a7c38279b0b 5 #define DROP 1
nene_kobayashi 2:3a7c38279b0b 6
nene_kobayashi 1:fa1980f9b2d0 7 MS5607I2C ms(p9,p10,false);
nene_kobayashi 0:027a3ffb7500 8 DigitalOut myled(LED1);
nene_kobayashi 2:3a7c38279b0b 9 pwmout servo1(p23);
nene_kobayashi 2:3a7c38279b0b 10 int Phase=RISE;
nene_kobayashi 2:3a7c38279b0b 11 Ticker tic;
nene_kobayashi 2:3a7c38279b0b 12 float max=0;
nene_kobayashi 2:3a7c38279b0b 13 int count=0;
nene_kobayashi 1:fa1980f9b2d0 14
nene_kobayashi 2:3a7c38279b0b 15 void judge(){
nene_kobayashi 2:3a7c38279b0b 16 switch(Phase){
nene_kobayashi 2:3a7c38279b0b 17 case RISE:
nene_kobayashi 2:3a7c38279b0b 18 float alt = ms.getAltitude();
nene_kobayashi 2:3a7c38279b0b 19 if(max <= alt){
nene_kobayashi 2:3a7c38279b0b 20 max = alt;
nene_kobayashi 2:3a7c38279b0b 21 }else if(max > alt){
nene_kobayashi 2:3a7c38279b0b 22 max = alt;
nene_kobayashi 2:3a7c38279b0b 23 count++;
nene_kobayashi 2:3a7c38279b0b 24 Phase=DROP1;
nene_kobayashi 2:3a7c38279b0b 25 }
nene_kobayashi 2:3a7c38279b0b 26 break;
nene_kobayashi 2:3a7c38279b0b 27
nene_kobayashi 2:3a7c38279b0b 28 case DROP1:
nene_kobayashi 2:3a7c38279b0b 29 if(count=5){
nene_kobayashi 2:3a7c38279b0b 30 servo1.pulsewidth(90);
nene_kobayashi 2:3a7c38279b0b 31 wait(1.0);
nene_kobayashi 2:3a7c38279b0b 32 }
nene_kobayashi 2:3a7c38279b0b 33 float alt = ms.getAltitude();
nene_kobayashi 2:3a7c38279b0b 34 break;
nene_kobayashi 2:3a7c38279b0b 35 }
nene_kobayashi 1:fa1980f9b2d0 36
nene_kobayashi 2:3a7c38279b0b 37 int main(){
nene_kobayashi 2:3a7c38279b0b 38 timer start();
nene_kobayashi 2:3a7c38279b0b 39 tic.attach(&judge,0.1);
nene_kobayashi 2:3a7c38279b0b 40 while(1);
nene_kobayashi 2:3a7c38279b0b 41 return 0;
nene_kobayashi 2:3a7c38279b0b 42 }