#define trigPin 7
#define echoPin 6
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration1, distance1;
duration1 = pulseIn(echoPin, HIGH);
distance1 = (duration1/2) / 29.1;
if (distance1 < 10)
{
Serial.println("the distance1 is less than 5");
delay(10000);
while (distance1 < 10)
{
Serial.println("the distancex is less than 5");
delay(500);
}
if(distance1 > 10)
{
Serial.println("the distance1 is greater than 5");
}
} }