   // simple stuff, if we are closer than 4cm trigger an action.
   if( current_distance < PROXY_SENS_TRIGGER_DISTANCE ){
     switchLights();
+    proxy_sens_last_action_triggered = ps_current_time;
   }
 }
 

// threshold value we trigger an action.
// we may want to wait 50ms between readings, since the waves may echo around for a while...
void updateProxySens(){
  if( ( millis() - proxy_sens_last_ping ) < PROXY_SENS_PING_SLEEP ){
    // we return, since we want to have some time between pings.
    return;
  }
  if( ( millis() - proxy_sens_last_action_triggered ) < PROXY_SENS_TRIGGER_SLEEP ){
    // means we will sleep for some time and don't trigger another action.
    return;
  }
  unsigned int uS = sonar.ping();
  //unsigned int uS = sonar.ping_median( 5 );
  int current_distance = (int)( uS / US_ROUNDTRIP_CM );
#ifdef PROXYSENS_DEBUG
  Serial << "ProxySens: distance is: " << current_distance << endl;


#include <NewPing.h>

#define proxy_sens_echo 10           // the pin to which the HC-SR04 echo pin has been attached.
#define proxy_sens_trig 12          // the pin to which the HC-SR04 trigger pin has been attached.
#define proxy_sens_max_distance 300 // the maximum distance.

int proxy_sens_basal_dist = 0;  // the basal, initial distance measured by the sensor.
