#include <NewPing.h>

int trigPin = 8 ;
int echoPin = 8 ;
int maxDistance = 400 ;

NewPing sensor(trigPin, echoPin, maxDistance) ;
float distance ;

void setup() {
 Serial.begin (9600);
}

void loop() {
 distance = sensor.ping_cm();
 
 if (distance <= 400 && distance >= 2)  {
  Serial.print(distance);
  Serial.println(" cm");
 }
 delay(100) ;
}