update hcsr04.cpp by changing 20000 to 2000

Dependencies:   Stepper mbed SDFileSystem Ultrasonic PinDetect millis

Revision:
6:354264d1e4bb
Parent:
4:63f0989c8d1e
Child:
7:ede305192e3b
--- a/main.cpp	Wed Dec 19 19:41:43 2018 +0000
+++ b/main.cpp	Wed Dec 19 19:44:16 2018 +0000
@@ -2,6 +2,7 @@
 #include "Stepper.h"
 #include "string"
 #include "hcsr04.h"
+#include "millis.h"
 Serial pc(USBTX, USBRX);
 HCSR04 heightsensor(PTA2,PTC2); //(trig,echo)
 HCSR04 pathsensor(PTD3,PTD2);
@@ -228,12 +229,20 @@
             }
     }    
 }
+
 void retract()
 {
-    while(homeSwitch == 1)
+    millisStart();
+    long Duration = 0;
+    long StartTime = millis();
+    
+    while(homeSwitch == 1 && Duration <= 48000 )
     {
     in1=0;
     in2=1;
+    long CurrentTime = millis();
+    Duration = CurrentTime-StartTime;
+    pc.printf("Duration = %d\r\n", Duration); 
     }
     in1=1;
     in2=1;
@@ -243,11 +252,10 @@
 { 
     in1=1;
     in2=0;
-    wait(14);
+    wait(48);
     in1=1;
     in2=1;
 }
-
 void internalpullups()
 {
     homeSwitch.mode(PullUp);