Ultrasonic sensor code problem

Hello...
I have a problem with my code
It returns 0.00 every time and I do not know why this happens
Code:

long duration_front , duration_right , duration_left , duration_back;
int Trig_pin_front = 24;
int Echo_pin_front = 25;
/*int Trig_pin_right = 27;
  int Echo_pin_right = 26;
  int Trig_pin_left = 28;
  int Echo_pin_left = 29;
  int Echo_pin_back = 23;
  int Trig_pin_back = 22;*/
float distance_front , distance_right , distance_left , distance_back;

void setup()
{
  Serial.begin(9600);
  pinMode(Echo_pin_front , INPUT);
  pinMode(Trig_pin_front , OUTPUT);
  /*pinMode(Echo_pin_right , INPUT);
    pinMode(Trig_pin_right , OUTPUT);
    pinMode(Echo_pin_left , INPUT);
    pinMode(Trig_pin_left , OUTPUT);
    pinMode(Echo_pin_back , INPUT);
    pinMode(Trig_pin_back , OUTPUT);*/
}


void ultrasonic_sensor(long duration , float distance , int Trig , int Echo)
{
  digitalWrite(Trig , HIGH);
  delay(10);
  digitalWrite(Trig , LOW);
  duration = pulseIn(Echo , HIGH);
  distance = duration * 0.034 / 2;
  if (distance > 400)
  {
    distance = 400;
  }
}


void loop()
{
  ultrasonic_sensor(duration_front , distance_front , Trig_pin_front , Echo_pin_front);
  Serial.print(distance_front);
  Serial.print("          \n");
}

Any observation?
Thanks!

You’re not returning any values from your ranging function.
You should not be passing in distance and duration - these should be locals with in the function.

It returns 0.00 again…

long duration_front , duration_right , duration_left , duration_back;
int Trig_pin_front = 24;
int Echo_pin_front = 25;
/*int Trig_pin_right = 27;
  int Echo_pin_right = 26;
  int Trig_pin_left = 28;
  int Echo_pin_left = 29;
  int Echo_pin_back = 23;
  int Trig_pin_back = 22;*/
float distance_front , distance_right , distance_left , distance_back;

void setup()
{
  Serial.begin(9600);
  pinMode(Echo_pin_front , INPUT);
  pinMode(Trig_pin_front , OUTPUT);
  /*pinMode(Echo_pin_right , INPUT);
    pinMode(Trig_pin_right , OUTPUT);
    pinMode(Echo_pin_left , INPUT);
    pinMode(Trig_pin_left , OUTPUT);
    pinMode(Echo_pin_back , INPUT);
    pinMode(Trig_pin_back , OUTPUT);*/
}


float ultrasonic_sensor(long duration , float distance , int Trig , int Echo)
{
  digitalWrite(Trig , HIGH);
  delay(10);
  digitalWrite(Trig , LOW);
  duration = pulseIn(Echo , HIGH);
  distance = duration * 0.034 / 2;
  if (distance > 400)
  {
    distance = 400;
  }
  return distance;
}


void loop()
{
  ultrasonic_sensor(duration_front , distance_front , Trig_pin_front , Echo_pin_front);
  Serial.print(distance_front);
  Serial.print("          \n");
}

Can someone help me?

try this (UNTESTED!)

int Trig_pin_front = 24;
int Echo_pin_front = 25;
/*int Trig_pin_right = 27;
  int Echo_pin_right = 26;
  int Trig_pin_left = 28;
  int Echo_pin_left = 29;
  int Echo_pin_back = 23;
  int Trig_pin_back = 22;*/
float distance_front , distance_right , distance_left , distance_back;

void setup()
{
  Serial.begin(9600);
  pinMode(Echo_pin_front , INPUT);
  pinMode(Trig_pin_front , OUTPUT);
  /*pinMode(Echo_pin_right , INPUT);
    pinMode(Trig_pin_right , OUTPUT);
    pinMode(Echo_pin_left , INPUT);
    pinMode(Trig_pin_left , OUTPUT);
    pinMode(Echo_pin_back , INPUT);
    pinMode(Trig_pin_back , OUTPUT);*/
}


float ultrasonic_sensor(int Trig , int Echo)
{
  digitalWrite(Trig , HIGH);
  delay(10);
  digitalWrite(Trig , LOW);
  float duration = pulseIn(Echo , HIGH);
  float distance = duration * 0.034 / 2;
  if (distance > 400)
  {
    distance = 400;
  }
  return distance;
}


void loop()
{
  distance_front = ultrasonic_sensor(Trig_pin_front , Echo_pin_front);
  Serial.print(distance_front);
  Serial.print("          \n");
}

hope that helps....

You need to assign the return value to a variable.

Bumping after less than ten minutes?
Get real.

Yes ,it works.I understood it.

Thanks a lot!!