Prototyp V2

Dependencies:   PM2_Libary

Branch:
michi
Revision:
79:368cbf09cf6a
Parent:
78:44291588a875
Child:
80:4eae727a13b5
diff -r 44291588a875 -r 368cbf09cf6a main.cpp
--- a/main.cpp	Wed Apr 27 10:59:11 2022 +0200
+++ b/main.cpp	Wed Apr 27 11:10:52 2022 +0200
@@ -130,30 +130,19 @@
 //returns 0 if there is NO object present
 //returns 1 if there is an object present
 //returns 2 if the distance isn't in the expected range
-int StepDetection(double distance){
+uint8_t StepDetection(double distance){
     double d_valueMM = distance;
-    if(d_valueMM >= 4) 
-    { 
-        return 0;
-    }
-    if(d_valueMM < 4)
-    { 
-         return 1;
-    }
-    if(d_valueMM < 0 || d_valueMM > 100 )
-    {
-         return 2;
-    }
-    else
-    {
-        return 2;
-    }
+    if(d_valueMM >= 4) return 0;
+    else if(d_valueMM < 4)  return 1;
+    else if(d_valueMM <= 0 || d_valueMM > 100 ) return 2;
+    else return 2;
 
 }
 /*Example implementation
  * distanceCM = mapping(analogIn.read()*3.3e3f);
  * stepDetected = StepDetection(distanceCM);
-*/
+ */
+
 
 // sets the Motor to a specified degree in one rotation 
 // PARAM: end_deg = new position of the arm in degree 0 <= value >=360