What exactly do you mean? I mean okay the pulseIn function by default waits for 1 sec for the pulse to be completed, or in my case, for the echo to go, strike the object and return. How would you determine the timeout limit? I mean the echo returns after different intervals of time depending upon the distance of the obstacle.
And your 40000L figure was also a bit confusing. Can you please elaborate on it?
Most confusing is using a one second busy-waiting function, because the maximum range of the HC-SR 04 sensor (as given by the manufacturer) is 3 meters. In case of max. range the ultrasonic ping sound is travelling 6 meters total (3 meters forth and echo sound three meters back to the sensor).
So you never have to wait a full second while sound is travelling much more than 300 meters, you have to wait just much shorter times for an echo. If that time has passed without getting an echo, you never will get a later echo from the same triggering.
For a rough estimation how long to wait: Calculate how much time it might take for sound to travel 6 meters!