termB 2回目 本番用

Dependencies:   MotorDriver_SU USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
12f2027a
Date:
Mon Nov 17 06:22:34 2014 +0000
Parent:
0:a66927a110ab
Commit message:
termB 2??(11/17)??????

Changed in this revision

termB-2.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a66927a110ab -r 1efcac695408 termB-2.cpp
--- a/termB-2.cpp	Sun Nov 16 17:45:56 2014 +0000
+++ b/termB-2.cpp	Mon Nov 17 06:22:34 2014 +0000
@@ -1,7 +1,7 @@
 #include "mbed.h"
 #include "MotorDriver_SU.h"
-
-
+ 
+ 
 DigitalIn sw(P0_1, PullUp);
 DigitalOut led(P1_28);
 AnalogIn   sw1(P0_22);
@@ -9,11 +9,11 @@
 AnalogIn   sw3(P0_14);
 AnalogIn   sw4(P0_11);
 AnalogIn   sw5(P0_13);
-
+ 
 MotorDriver_SU motor(MOTOR_DOUBLE);
 MotorDriver_SU lift(MOTOR_SINGLE);
-
-
+ 
+ 
 int main( ){
     float hoge1;
     float hoge2;
@@ -31,6 +31,10 @@
         hoge4 = sw4.read();
         hoge5 = sw5.read();
         
+        while(sw == 0){
+                motor.Drive(0, STOP, 0); 
+                motor.Drive(1, STOP, 0);       
+        }
         
         /************************************/
         /*ラインに沿って走るためのプログラム*/
@@ -39,7 +43,7 @@
         /*黒_白_白_白_白*/
         if(sw1  <= 0.3 && sw2 > 0.5 && sw3 > 0.5 && sw4  > 0.5 && sw5 > 0.5){     
             motor.Drive(0, CW, 500);           
-            motor.Drive(1, CW, 2000);             
+            motor.Drive(1, CW, 1500);             
             
         }
         
@@ -47,26 +51,26 @@
         /*白_黒_白_白_白*/
         else if(sw1  > 0.5 && sw2 <= 0.3 && sw3 > 0.5 && sw4 > 0.5 && sw5 > 0.5){   
             motor.Drive(0, CW, 800);           
-            motor.Drive(1, CW, 2000);           
+            motor.Drive(1, CW, 1500);           
             
         }
         /*白_黒_黒_白_白*/
         else if(sw1  > 0.5 && sw2 <= 0.5 && sw3 <= 0.5 && sw4 > 0.5 && sw5 > 0.5){   
             motor.Drive(0, CW, 1000);         
-            motor.Drive(1, CW, 2000);        
+            motor.Drive(1, CW, 1500);        
             
         }
         
         
         /*白_白_黒_白_白*/
         else if(sw1  > 0.5  && sw2  > 0.5 && sw3 <= 0.3 && sw4  > 0.5 && sw5 > 0.5){  
-            motor.Drive(0, CW, 1600);        
-            motor.Drive(1, CW, 1600);     
+            motor.Drive(0, CW, 1500);        
+            motor.Drive(1, CW, 1500);     
             
         }
         /*白_白_黒_黒_白*/
         else if(sw1  > 0.5 && sw2 > 0.5 && sw3 <= 0.5 && sw4 <= 0.5 && sw5 > 0.5){   
-            motor.Drive(0, CW, 2000);         
+            motor.Drive(0, CW, 1500);         
             motor.Drive(1, CW, 1000);        
             
         }
@@ -74,8 +78,8 @@
         
         
         /*白_白_白_黒_白*/
-        else if(sw1  > 0.5 && sw2  > 0.5 && sw3  > 0.5 && sw4 <= 0.5 && sw5 > 0.5){  
-            motor.Drive(0, CW, 2000);       
+        else if(sw1  > 0.5 && sw2  > 0.5 && sw3  > 0.5 && sw4 <= 0.3 && sw5 > 0.5){  
+            motor.Drive(0, CW, 1500);       
             motor.Drive(1, CW, 800);           
             
         }
@@ -83,7 +87,7 @@
         
         /*白_白_白_白_黒*/
         else if(sw1  > 0.5 && sw2  > 0.5 && sw3  > 0.5 && sw4  > 0.5 && sw5 <= 0.3){  
-            motor.Drive(0, CW, 2000);        
+            motor.Drive(0, CW, 1500);        
             motor.Drive(1, CW, 500);       
         
         }
@@ -161,24 +165,26 @@
         /**********************************/
         
         /*1.4.1 センサ1-5が黒*/
-        else if(sw1  <= 0.5 && sw5 <= 0.5){     
-            motor.Drive(0, STOP, 0);           
-            motor.Drive(1, STOP, 0);             
+        else if(sw1  <= 0.5 && sw5 <= 0.5){
+               
+            
+                      
             if( updown == 0 ){
                 ///////////停止//////////
                 motor.Drive(0, STOP, 0);           
                 motor.Drive(1, STOP, 0);
                 wait(0.1);
                 ///////////リフト上げる//////////
-                lift.Drive(0, CCW, 4095);
+                lift.Drive(0, CCW, 2000);
                 wait(1.0);
                 ///////////リフト停止//////////
                 lift.Drive(0, STOP, 0);
                 wait(0.1);
                 ///////////停止位置を超えるために少し前進//////////
+                
                 motor.Drive(0, CW, 1500);           
                 motor.Drive(1, CW, 1500);
-                wait(1.0);
+                wait(0.1);
                 updown = 1;
             }
             
@@ -196,7 +202,7 @@
                 ///////////バック//////////
                 motor.Drive(0, CCW, 4095);           
                 motor.Drive(1, CCW, 4095);
-                wait(3.0);
+                wait(1.2);
                 ///////////モータ停止//////////
                 motor.Drive(0, STOP, 0);           
                 motor.Drive(1, STOP, 0);