Tuk workshop

Dependencies:   mbed RC_Servo VMA306 PID CNY70 CMPS03 GP2A Pixy

Files at this revision

API Documentation at this revision

Comitter:
tuk4
Date:
Fri Nov 01 08:30:33 2019 +0000
Parent:
17:961a91037658
Commit message:
Committed on 1/11/2019 11:28 am

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 961a91037658 -r 96264a9ddaf6 main.cpp
--- a/main.cpp	Thu Oct 31 16:13:21 2019 +0000
+++ b/main.cpp	Fri Nov 01 08:30:33 2019 +0000
@@ -51,6 +51,7 @@
     motor.setintegralValue(0.4);
     motor.setDerivativeValue(1.0);
     double speed_L = -200, speed_R = -200;
+    bool reset = false;
     while (1) {
 
         motor.getPosition(&x, &y, &theta);
@@ -83,10 +84,12 @@
                 if (ultraSon.readUSB() <= 20) {
                     current_state = SAFEMODE;
                 }
-                if (left_center.whatAmIOn()== 0)
+                if (left_center.whatAmIOn()== 0 && reset == false)
                 {
                     led1==1;
                     motor.resetPosition();
+                    reset = true;
+                    
                 }
                 if (x<=-1300) current_state = STUPID1;
                 break;