help about multiple sensors

hi
I want to use two hc-sr04 distance sensor and two servo. servo must be only two angle. how can i do that?( I did for one servo and sensor)

#include <Servo.h>

Servo sMotor;
int ref[4] = {42, 43, 41, 44};   //cisim yokken olan mesafe
int aci[4] = {87, 120, 78, 92};   //slotlara bakan açı değerleri
char park_state[8] = {0,0,0,0,0,0,0,0};    //gönderilecek string bu :D
int state = 0;
long echo_time;
const int trigPin = 12;
const int echoPin = 11; 


long mesafeOlcumu(){
  long sure;
  long uzaklik;
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(30);
  digitalWrite(trigPin, HIGH); 
  delayMicroseconds(20);
  digitalWrite(trigPin, LOW);  
  sure = pulseIn(echoPin, HIGH, 11600);
  uzaklik= sure /29.1/2;    
  if(uzaklik > 200 || uzaklik < 1 )
    uzaklik = 200;
  return uzaklik;
}

void mesafe_isle(int state, long mesafe){
  long tmp = ref[state] - mesafe;
  park_state[state + 4] = park_state[state];
  if(tmp > 1)
    park_state[state] = '1';
  else
    park_state[state] = '0';
}

bool hata_tespiti(long e) {
  if(30 < e && e < 60)
    return false;
  else
    return true;
}
void debug(int s) {
  Serial.print(s);
  Serial.print("'inci slotun uzakligi: ");
  Serial.println(echo_time);
  Serial.print(" Arac ");
    if(park_state[s] == '1')
      Serial.println("var.");
    else
      Serial.println("yok.");
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  sMotor.attach(9);
  pinMode(trigPin, OUTPUT); 
  pinMode(echoPin,INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
    sMotor.write(aci[state]);
    delay(2000);
    do{
      echo_time = mesafeOlcumu();
    }while(hata_tespiti(echo_time));
    mesafe_isle(state, echo_time);
    debug(state);
    if(state == 1)
      state = 0;
    else
      state++; 
}

You would add similar code for the second sensor as you have for the first. What part is bothering you? Can you be a little more specific with your question?

i guess the problem is delay. values are changing

Have a look at how millis() is used to manage timing without blocking in Several things at a time

Also I wonder if it is necessary to use WHILE as that also blocks until it completes.

...R