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

Dependencies:   mbed MS5607 MPU6050

Files at this revision

API Documentation at this revision

Comitter:
nene_kobayashi
Date:
Sat Aug 05 13:44:05 2017 +0000
Parent:
1:fa1980f9b2d0
Child:
3:507d05fb5cd8
Commit message:
???????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Jul 23 14:25:42 2017 +0000
+++ b/main.cpp	Sat Aug 05 13:44:05 2017 +0000
@@ -1,24 +1,42 @@
 #include "mbed.h"
 #include "MS5607I2C.h"
 
+#define RISE 0
+#define DROP 1
+
 MS5607I2C ms(p9,p10,false);
 DigitalOut myled(LED1);
-
-float max;
+pwmout servo1(p23);
+int Phase=RISE;
+Ticker tic;
+float max=0;
+int count=0;
 
-int main() {
-    
-    max=0;
+void judge(){
+     switch(Phase){
+        case RISE:
+                float alt = ms.getAltitude();
+                if(max <= alt){
+                    max = alt;
+                }else if(max > alt){ 
+                    max = alt;
+                    count++;
+                    Phase=DROP1;
+                }
+                break;
+                
+        case DROP1:
+                if(count=5){
+                    servo1.pulsewidth(90);
+                    wait(1.0);
+                }
+                    float alt = ms.getAltitude();
+                break;
+}
     
-    while(1){ 
-      
-     float alt = ms.getAltitude();
-     
-     if(max <= alt){
-         max = alt;
-     }else if(max > alt){ 
-      myled = 1;
-     }
-        
-    }
-}
+int main(){
+    timer start();
+    tic.attach(&judge,0.1);
+    while(1);
+    return 0;
+}
\ No newline at end of file