main

Dependencies:   Stepper mbed Ultrasonic PinDetect millis

Revision:
5:e958d61e0564
Parent:
4:1a4022b21dae
Child:
6:6ca8a0ef7d4a
--- a/main.cpp	Fri Nov 16 20:17:04 2018 +0000
+++ b/main.cpp	Wed Dec 19 19:39:25 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);
@@ -22,7 +23,13 @@
     int fp = 457; //adjust if needed
     int lp = 64;  //adjust if needed
     int tp = 25;  
-    
+    wait(1);
+    in1=1;
+    in2=0;
+    wait_ms(600);
+    in1=1;
+    in2=1;
+    wait(1);
     while (plates!=sheets) {
         heightsensor.start();
         wait_ms(500);
@@ -230,10 +237,17 @@
 }
 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,7 +257,7 @@
 { 
     in1=1;
     in2=0;
-    wait(17);
+    wait(48);
     in1=1;
     in2=1;
 }