Servo sensor issue

hey im making a sensor using a servo and SRF05

and im using the tutorial for ping and sweep together, and i'm having an issue on thE coding where the servo stops when a object is detected.

You have not shown any code or described what the issue is.

#include <Servo.h>
#define trigPin 7

#define echoPin 6

Servo servo;

void setup()

{

Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

servo.attach(8);

}

void loop()

{

long duration, distance;

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);

distance = (duration/2) / 29.1;

if (distance < 5)

{

Serial.println(“the distance is less than 5”);

servo.write(120);

}

else

{

servo.write(0);

}

if (distance > 60 || distance <= 0)

{

Serial.println(“The distance is more than 60”);

}

else

{

Serial.print(distance);

Serial.println(" cm");

}

delay(500);

}

this is the code so far, i having an issue f adding a statement when a object is detected the servo stops and when it is move it starts again

this is the code so far

Improperly posted and crappily indented. Code tags and Tools + Auto Format.

Step 1) Put the code to read the ping sensor in a function. Call the function from loop().

Step 2) PRINT THE VALUE THAT YOU GET BACK.

Under what circumstances should the servo stop? Under what circumstances should the servo move to a different position?

the servo should stop when the sensor detects an object, and when the object is removed, the servo should continue scanning. I'm basically new to this and trying to make a ultrasonic sensor which detects objects

Is the servo waving the distance sensor around?

What does the code actually do? How does that differ from what you want?