レーザー用のプログラムです(複数不可) 正規の方法じゃないから問題が起こるかもね がんばって

Dependencies:   mbed

Fork of VL53L0X_STM32compatible_2 by 2018年春ロボ1班

Files at this revision

API Documentation at this revision

Comitter:
riku3141
Date:
Tue Dec 26 05:35:10 2017 +0000
Parent:
2:30363c43d575
Commit message:
test

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Dec 26 03:39:31 2017 +0000
+++ b/main.cpp	Tue Dec 26 05:35:10 2017 +0000
@@ -21,6 +21,7 @@
 Ticker  TT;                     //call a timer
 //~~~VL53L0X_I2C~~~//
 int     Distance = 0;
+int     Distance_2 = 0;
 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑end of Varible registor↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑//
 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓Function registor↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
 void    init_TIMER();           //set TT_main() rate
@@ -35,9 +36,32 @@
 }
 void TT_main()                      //interrupt function by TT 測定用関数
 {
+//for Serial-Oscilloscope
+    
+    pc.printf("number: %d ;;",sensor.address);
     Distance = sensor.readRangeContinuousMillimeters();
-//for Serial-Oscilloscope
     pc.printf("%d         ", Distance);
+    sensor.address=41;
+    pc.printf("number: %d ;;",sensor.address);
+    Distance_2 = sensor.readRangeContinuousMillimeters();
+    pc.printf("%d         ", Distance_2);
+    sensor.address=84;
+    if(Distance==Distance_2){
+        pc.printf("error");
+    }
+    else 
+    if(abs(Distance+13-Distance_2)>10){
+        if(Distance+13>Distance_2){
+            pc.printf("move left");
+        }
+        else{
+            pc.printf("move right");
+        }
+    }
+    else{
+        pc.printf("OK");
+    }
+    pc.printf("\r");
 }
 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑end of Timebase funtion↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑//
 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓init_IO funtion↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
@@ -82,17 +106,9 @@
     sensor.address=84;
 //    reset = 0;
     while(1) {                  //main() loop
-        reset =1;
-        pc.printf("number: %d ;;",sensor.address);
+//        wait(0.1);
         TT_main();
         sensor.address=41;
-//        wait(0.1);
-        pc.printf("number: %d ;;",sensor.address);
-        TT_main();
-        sensor.address=84;
-        pc.printf("\r");
-//        wait(0.1);
-        sensor.address=41;
         pc.printf("button state %d      \n", button.read());
         if(button.read()==0){
             sensor.init();