People Counter / Mbed 2 deprecated person_counter

Dependencies:   mbed mbed-rtos 4DGL-uLCD-SE HC_SR04_Ultrasonic_Library

Revision:
24:fd113f826c98
Parent:
23:f877b13f22b7
Child:
25:577a78b97309
--- a/main.cpp	Sun Apr 26 21:15:38 2020 +0000
+++ b/main.cpp	Mon Apr 27 21:58:28 2020 +0000
@@ -74,17 +74,17 @@
         {
              ++non_zeros;           //Incriment non_zero counter
              //allZero = false;
-             if(non_zeros > 1)      //If there is more than one non zero
+             if(non_zeros > 2)      //If there is more than one non zero
             {
                 allZero = false;    //Change the allZero flag to false
             }
         }
         //NEW CODE
-        if(values[i] < values[(i+1)%5] && values[(i+1)%5] < values[(i+2)%5])
+        if(values[i] < values[(i+1)%5] && values[(i+1)%5] < values[(i+2)%5] && values[i] !=0)
         {
             movingAway = true;      //Person moving away from sensor
         }
-        if (values[i] > values[(i+1)%5] && values[(i+1)%5] > values[(i+2)%5])
+        if (values[i] > values[(i+1)%5] && values[(i+1)%5] > values[(i+2)%5] && values[(i+2)%5] !=0)
         {
             movingTowards = true;   //Person moving to the sensor
         }