this is made by seminal03_2015_SIT_mechanical_engineering

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
mbed2015
Date:
Thu Feb 04 02:13:29 2016 +0000
Commit message:
???????PaPIRs EKMC1601111?????????????????????????????????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Feb 04 02:13:29 2016 +0000
@@ -0,0 +1,125 @@
+#include "mbed.h"
+
+/*センサ安定時間*/
+#define INIT 30.0
+/*ノイズ検出用*/
+#define NOISE 0.5
+/*センサ再読み取り時間*/
+#define DELAY 0.5
+
+Serial pc(USBTX, USBRX); 
+
+Ticker flipper;
+Timer t1;
+Timer t2;
+DigitalIn pA (p19);
+DigitalIn pB (p20);
+DigitalOut led1 (LED1);
+DigitalOut led2 (LED2);
+
+void flip(){
+    led1 = !led1;
+    }
+
+//VAout hosei 
+int main(void)
+{
+    flipper.attach(&flip,0.3);     
+    wait(INIT);
+    flipper.detach();
+    
+    double valpA;
+//    double valpB;
+    double timehigh;
+    double timelow; 
+    double t;
+    
+    double sumvalA;   
+
+    int a = 0;
+  
+    printf("high time no sokutei\n");
+    while(1)
+    {
+        while(pA == 1){}
+        while(pA != 1){}        
+        t1.start();
+        while(pA == 1){}
+        t=t1.read();
+        pc.printf("t1=%f\n",t);
+        while(a == 0 || t >0.5)
+        {
+            if(pA != 1 )
+            {
+                t2.start();
+                while(pA != 1){}
+                t2.stop();
+                timelow = t2.read();
+                pc.printf("lowtime=%f\n",timelow);
+                if(timelow > 0.4){
+                    t1.stop();
+                    timehigh = t1.read() - t2.read();
+                    pc.printf("timehigh = %f\n",timehigh);
+                    a ++;
+                }else{
+                    pc.printf("continue\r\n");
+                }
+            t2.reset();
+            t = t1.read();
+            }
+        }
+        t1.reset();
+    }
+/*  
+    while(1){  
+    if(pA == 1){
+        valpA = pA.read();
+        pc.printf("%2.1f\n",valpA);
+    }
+    wait(1);
+    }
+*/
+/*     
+
+int main() {
+    
+    int a = 0;
+    int b = 0;
+    int plus = 0;
+//    int minus = 0;
+//    int sum = 0;    
+    led1 = 0;
+    led2 = 0;
+    led3 = 0;
+    led4 = 0;
+    
+
+    pc.printf("a=%d b=%d\n",a,b);
+    
+//    t.start(); //60sごとにループを抜ける
+
+        while(t != 60){
+            if(pA){
+                wait(NOISE);
+                if(pA){ 
+                    a ++;
+                    pc.printf("a=%d\n",a);
+                    wait(DELAY);
+                    if(pB){
+                        wait(NOISE);
+                        if(pB){
+                            b ++;
+                            pc.printf("b=%d\n",b);
+                            wait(DELAY);
+                            plus ++;
+                            pc.printf("plus=%d\n",plus);
+                        }
+                    }
+                }
+            wait(DELAY);
+            }
+        }
+    
+}
+*/
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 04 02:13:29 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file