Takuya Kobayashi / Mbed 2 deprecated mbed_linetrace_termB_test

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
kamorei
Date:
Tue Oct 30 06:32:38 2018 +0000
Parent:
2:8748af75523f
Commit message:
10/30 ?????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 30 06:24:21 2018 +0000
+++ b/main.cpp	Tue Oct 30 06:32:38 2018 +0000
@@ -182,6 +182,7 @@
                 break;
             }
         }
+        
         //以下トンネル内部
         if( i < 2){
             turn_right();
@@ -191,6 +192,9 @@
                 turn_right();
                 if( sensor[3] <= blackR){
                     stop_turn_right();
+                    
+                    wait(0.5);
+                    
                     break;
                 }
             }
@@ -203,7 +207,9 @@
             
             white_tunnel = sensorL.read();
             gray_tunnel = (white_tunnel - black_tunnel) / 2;
-            while(1){ //姿勢を直す
+            
+            //姿勢を直す
+            while(1){
                 sensor[3] = sensorR.read();
                 turn_left();
                 if( sensor[3] <= blackR){
@@ -211,6 +217,28 @@
                     break;
                 }
             }
+            
+            //トンネルに入る
+            while(1){
+                sensor[0] = sensorL.read();
+                sensor[1] = sensorCL.read();
+                sensor[2] = sensorCR.read();
+                sensor[3] = sensorR.read();
+                
+                pr = (sensor[2] - black) / (white - black);
+                pl = (sensor[1] - black) / (white - black);
+                
+                go_straight_p();
+                
+                if( sensor[1] < gray_tunnel && sensor[2] < gray_tunnel){
+                    stop_point();
+                    ledRR = 0b11;   //←2進数表記使える…?
+                    wait(0.5);
+                    break;
+                }
+            }
+            
+            //トンネルの中でのトレース
             while(1){
                 sensor[0] = sensorL.read();
                 sensor[1] = sensorCL.read();