This is a bare setup. The ping ))) sensor has on-board electronics that sends out ultrasonic pulses and senses the reflected pulses and produces a single pulse as a reply to a microcontroller, proportional to distance. This thing needs you to monitor all pulses that reflect back and possibly amplify the reflected signal to detect them.
In any case, don't use pin 0. That is the rx pin for your Serial.xxx() stuff.
The sample code at the site you posted the link recommends a 300us pulse to acquire a signal. A 2us or 5us pulse is not nearly long enough to acquire a signal on a 40khz audio pulse (25us per cycle). That would not even be one cycle. You will probably need 5-10 cycles to acquire.
liudr:
This is a bare setup. The ping ))) sensor has on-board electronics that sends out ultrasonic pulses and senses the reflected pulses and produces a single pulse as a reply to a microcontroller, proportional to distance. This thing needs you to monitor all pulses that reflect back and possibly amplify the reflected signal to detect them.
OP,
As I said a million years ago on the above reply, your code will NEVER work. The code is for Parallax ping ))) sensor and what you made out of parts is not ping ))) sensor. I don't have code for your basic setup but if you really want to save money, why not getting this ping-compatible sensor for cheap to save yourself from the trouble?