last

Dependencies:   MotorDriver_SU mbed

Fork of finalcenter by Naoki Hasegawa

Files at this revision

API Documentation at this revision

Comitter:
12f2039e
Date:
Sun Nov 23 09:08:39 2014 +0000
Parent:
0:cc0c03ee56b3
Commit message:
last

Changed in this revision

center.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/center.cpp	Wed Nov 19 13:08:25 2014 +0000
+++ b/center.cpp	Sun Nov 23 09:08:39 2014 +0000
@@ -36,18 +36,20 @@
                 motor.Drive(1, CW, 1500);
                 }
             else if(sensor1 == 1 && sensor2 == 0 && sensor3 == 1 && sensor4 == 1 && sensor5 == 1){
-                motor.Drive(0, CW, 1000);
-                motor.Drive(1, CW, 1000);
+                motor.Drive(0, CW, 1700);
+                motor.Drive(1, CW, 1700);
                 lift.Drive(0, STOP, 0);
                 }
             else if(sensor1 == 1 && sensor2 == 0 && sensor3 == 1 && sensor4 == 0 && sensor5 == 0){
+                led = 1;//count kakuninn
                 if( count == 0){
                     lift.Drive(0, CW, 4095); //lift up
                     motor.Drive(0, STOP, 0); //stop
                     motor.Drive(1, STOP, 0);
                     wait(1);
-                    motor.Drive(0, CW, 1000); //restart
-                    motor.Drive(1, CW, 1000); 
+                    led = 0;//count kakuninn
+                    motor.Drive(0, CW, 2000); //restart
+                    motor.Drive(1, CW, 2000); 
                     lift.Drive(0, CW, 4095); //lift up more
                     wait(0.7);
                     lift.Drive(0, STOP, 0);
@@ -69,6 +71,7 @@
                     motor.Drive(0, CCW, 4095);//back for 2 seconds
                     motor.Drive(1, CCW, 4095);
                     lift.Drive(0, STOP, 0);
+                    led = 0;//count kakunin
                     wait(2);
                     //height = 0;//lift position low
                     count = 0;//reset
@@ -79,7 +82,7 @@
                 }
             else if(sensor1 == 0 && sensor2 == 1 && sensor3 == 1){
                 motor.Drive(0, CW, 1500);
-                motor.Drive(1, STOP, 500);
+                motor.Drive(1, CW, 500);
                 }
             else if(sensor1 == 0 && sensor2 == 0 && sensor3 == 1){
                 motor.Drive(0, CW, 1500);
@@ -90,8 +93,8 @@
                 motor.Drive(1, CW, 1500);
                 }
             else if(sensor1 == 0 && sensor2 == 1 && sensor3 == 0){
-                motor.Drive(0, CCW, 500);
-                motor.Drive(1, CCW, 500);
+                motor.Drive(0, CW, 500);//ccw  change cw
+                motor.Drive(1, CW, 500);//ccw  change cw
                 }
             /*else if(sensor1 == 1 && sensor2 == 1 && sensor3 == 1){
                 motor.Drive(0, CW, 2048);
@@ -108,6 +111,9 @@
             else if(sensor2 == 0 && sensor4 == 1 && sensor5 == 0){
                         if(check1 == 0){
                             check1 = 1;
+                            motor.Drive(0, CW, 1000);//adjust
+                            motor.Drive(1, CW, 1000);
+                           wait(0.5);//adjust
                         //enter the right courses
                             motor.Drive(0, CW, 500);//change both speed
                             motor.Drive(1, CW, 1500);
@@ -125,10 +131,17 @@
                             motor.Drive(1, CW, 500);
                             wait(1);
                             }
+            else if(sensor1 == 0 && sensor2 == 0 && sensor3 == 0 ) {
+                motor.Drive(0, CW, 500);
+                motor.Drive(1, CW, 500);
+                }//tuika
+                         
+                            
                         else{
                                 ;//response only once
                                 }
                     }
+                    
             else{
                 motor.Drive(0, CW, 2500);//spin to search correct way
                 motor.Drive(1, CW, 500);