Or you can buy a Ping ultrasonic sensor from Parallax (or a similar sensor from another vendor) and save yourself the trouble of trying to develop your own ultrasonic ranging sensor (which isn't a trivial project); unless your goal is to learn how to build such a sensor, you will end up spending far more money and time than if you purchase such an ultrasonic ranger sensor. The Ping sensor is but one device; other vendors sell similar devices, then there are ones from Maxbotics, and a few other companies (there's a very expensive, but narrow beam one that uses the same sensor as old Polaroid cameras made by SensComp). Which brings up another possibility - pull the sensor out of an old Polaroid camera and hack that (Sun 660 and the Spectra are popular models with the sensor - tons of info online about hacking both cameras for use with microcontrollers).