a

Dependencies:   MotorDriver_SU mbed

Fork of tracer by Naoki Hasegawa

Files at this revision

API Documentation at this revision

Comitter:
12f2039e
Date:
Fri Oct 31 06:51:49 2014 +0000
Parent:
1:faa0499314d3
Commit message:
a

Changed in this revision

tracer.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/tracer.cpp	Thu Oct 30 11:45:35 2014 +0000
+++ b/tracer.cpp	Fri Oct 31 06:51:49 2014 +0000
@@ -6,69 +6,68 @@
 DigitalIn sensor2(P0_13);
 DigitalIn sensor3(P0_11);
 // lift L to R
-DigitalIn sensor4(P1_27);
-DigitalIn sensor5(P0_4);
+DigitalIn sensor4(P0_12);
+DigitalIn sensor5(P0_14);
 
 MotorDriver_SU motor(MOTOR_DOUBLE);
 MotorDriver_SU lift(MOTOR_SINGLE);
 
-int height = 0;
-int a = 0;
-
 int main(){
+    int height = 0;
+    int a = 0;
     while(1){
         while(a == 0){
         //patern1
             if(sensor1 == 1 && sensor2 == 1 && sensor3 == 0){
-                motor.Drive(0, CW, 300); //右タイヤ
-                motor.Drive(1, CW, 1500);//左タイヤ
+                motor.Drive(0, CW, 0); //右タイヤ
+                motor.Drive(1, CW, 2000);//左タイヤ
                 }
         //patern2
             else if(sensor1 == 1 && sensor2 == 0 && sensor3 == 1){
-                motor.Drive(0, CW, 1500);
-                motor.Drive(1, CW, 1500);
+                motor.Drive(0, CW, 1000);
+                motor.Drive(1, CW, 1000);
                 }
         //patern3
             else if(sensor1 == 0 && sensor2 == 1 && sensor3 == 1){
-                motor.Drive(0, CW, 1500);
-                motor.Drive(1, CW, 300);
+                motor.Drive(0, CW, 2000);
+                motor.Drive(1, CW, 0);
                 }
         //patern4
             else if(sensor1 == 0 && sensor2 == 0 && sensor3 == 1){
-                motor.Drive(0, CW, 800);
+                motor.Drive(0, CW, 0);
                 motor.Drive(1, CW, 1500);
                 }
         //patern5
         else if(sensor1 == 1 && sensor2 == 0 && sensor3 == 0){
             motor.Drive(0, CW, 1500);
-            motor.Drive(1, CW, 800);
+            motor.Drive(1, CW, 0);
             }
         //patern6
             else if(sensor1 == 0 && sensor2 == 0 && sensor3 == 0){
-                motor.Drive(0, CW, 1500);
-                motor.Drive(1, CW, 1500);
+                motor.Drive(0, CW, 1000);
+                motor.Drive(1, CW, 1000);
                 }
         
         //patern7
             else if(sensor1 == 0 && sensor2 == 1 && sensor3 == 0){
-                motor.Drive(0, CW, 1500);
-                motor.Drive(1, CW, 1500);
+                motor.Drive(0, CW, 1000);
+                motor.Drive(1, CW, 1000);
                 }
-        /*
+        
         //patern8 探索回転方向
         //ラインの右側に出た場合 反時計回り
-            else if(sensor1 == 1 && sensor2 == 1 && sensor3 == 1 && hasegawa == 0){
+            /*else if(sensor1 == 1 && sensor2 == 1 && sensor3 == 1){
                     motor.Drive(0, CW, 2048);
-                    motor.Drive(1, CW, 1000);
+                    motor.Drive(1, STOP, 0);
                     }*/
-        /*//ラインの左側に出た場合 時計回り
-            else if(sensor1 == 1 && sensor2 == 1 && sensor3 == 1 && hasegawa == 1){
-                    motor.Drive(0, CW, 1000);
-                    motor.Drive(1, CW, 2048);
-                    }*/
+        //ラインの左側に出た場合 時計回り
+            else if(sensor1 == 1 && sensor2 == 1 && sensor3 == 1 ){
+                    motor.Drive(0, STOP, 0);
+                    motor.Drive(1, CW, 1500);
+                    }
             
         //リフト判定
-        /*  else if(sensor4 == 0 && sensor5 == 0, height == 0){
+        else if(sensor4 == 0 && sensor5 == 0, height == 0){
                     //ストップ
                     motor.Drive(0, STOP, 0);
                     motor.Drive(1, STOP, 0);
@@ -76,7 +75,8 @@
                     lift.Drive(0, CW, 2000); //リフトアップ
                     wait(4);
                     lift.Drive(0, STOP, 0);
-                    height = 1; //lift位置
+                    height = 1;
+                    wait(1); //lift位置
                      //再スタート
                     motor.Drive(0, CW, 1500);
                     motor.Drive(1, CW, 1500);
@@ -88,20 +88,21 @@
                     lift.Drive(0, CCW, 2000);//リフトダウン
                     wait(4);
                     lift.Drive(0, STOP, 0);
-            
+                    
+                    height = 0;
                     a = 1;// スルー判定
-                    }*/
+                    }
             
             else{
-                motor.Drive(0, CW, 1500);
-                motor.Drive(1, CW, 1500);
+                motor.Drive(0, CW, 1000);
+                motor.Drive(1, CW, 1000);
                 }
         }
-        //後退
-        /*while( a == 1){
+        //back 
+        while( a == 1){
                     motor.Drive(0, CCW, 3000);
                     motor.Drive(1, CCW, 3000);
-                    }*/
+                    }
             
     }