working with Chinese car parking sensors ...

hi all
at first I am sorry for my weak language ..
I am using car parking piezo electric sensors for distance measurements ..
I have made a Transmitting and receiving circuit that can sense reflected Echo up to 3 meters ...
I am using two different sensors one for transmitting and one for receiving ...
I am getting 5 v pulse when any reflected signal received ..
all what I need is to calculate the time between transmitting and receiving signals to get the distance...

I am using Tone() code to generate 40 khz signal to drive the transmitter transistor.
I have tried to write a code for that but when echo received I got almost the same result whatever the distance is ...
I always get values like 4 , 8, 12 almost in a random manner using macros() ...
I have attached a buzzer into Echo pin to hear and test the reflected echo and I have got very clear buzzer pulse ..
also there is no noise in the circuit I mean when there is no Echo,, the Echo Pin digital read is always 0
this is my code
any help will be greatly appreciated ...

float startt, endd;
void setup() {
  
  pinMode(3, OUTPUT);      // 40 khz pin
 
  pinMode(A0, INPUT);     // Echo Pin
 Serial.begin(9600);  
}

void loop(){
  
 // Transmitting 40khz signal 
 
   digitalWrite(3, LOW);  
   tone(3,40000);
   delay(50);
   noTone(3);
   startt = micros();  // record transmitting pulse time
  
  
  // Waiting for the reflected Echo.
  
  if (digitalRead(A0) == HIGH) {     
     
   
    endd= micros();  // record received Echo time.
     Serial.println(endd-startt);
    
    delay(100);
 
  } 
  else {
   
       
         Serial.println("No Signal Received");
        
  }
}

delay(50);
This is one problem. You're sending a burst that is 50000 microseconds long and then looking for the echo of the beginning of that burst. In that 50000 microseconds the sound will have traveled over 17 meters! If you want to catch the leading edge of the echo off an object a meter away you have to start looking for it within 2 milliseconds. I would reduce the burst length to 1 millisecond or even less. Each cycle of the output takes 25 microseconds so start with that and increase the length until you get a good results.

startt = micros(); // record transmitting pulse time
If you are looking for the leading edge of the echo you probably want to start the timer at the START of the output, not at the end.

  if (digitalRead(A0) == HIGH) {     
     endd= micros();  // record received Echo time.
     Serial.println(endd-startt);
    delay(100);
  }

This does not look for the leading edge of the echo. It just checks to see if the leading edge of the echo passed by in the 50000 microseconds since the output burst started. You will need some way to detect the start of the echo. The digitalRead() function is fairly slow so if you use that in a loop you are going to get low resolution. You should at least use direct port access.