4 Servos and sonar

i posted a a question on gow to make 4 servo controlled by a sonar… so far i manage to wire 4 servo and they are all running together no i want it to be controlled by a sonar the idea is once the sonar detects a movement the servo move from 0 to 180 degrees… i bought the LV- maxzonar i need help on combining the sonar codes and the for servo codes.

here is the code for four servo

// Sweep
// by BARRAGAN http://barraganstudio.com

#include <Servo.h>

Servo myservo1; // create servo object to control servo1
Servo myservo2; // create servo object to control servo2
Servo myservo3; // create servo object to control servo3

int pos = 0; // variable to store the servo position

void setup()
{

myservo1.attach(8); // attaches the servo on pin 9 to the servo object

myservo2.attach(9); // attaches the servo on pin 10 to the servo object

myservo2.attach(9); // attaches the servo on pin 10 to the servo object
}

void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree

myservo1.write(pos); // tell servo to go to position in variable ‘pos’
myservo2.write(pos);
delay(15); // waits 15ms for the servo to reach the position

}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{

myservo1.write(pos); // tell servo to go to position in variable ‘pos’
myservo2.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}
}

i need help on sonar thanks