TeamMCS made a really neat and easy to use Arduino library.
This library is intended to make life a little easier by encapsulating the measurement and serial functionality. Everything is handled for you with minimal delays so you can avoid blocking.
First up, we've made a slight modification to the NewSoftwareSerial library to include "new/delete" operators. I wasn't aware that the AVR C++ libraries excluded support of the implicit "new" operator, which also meant the library wouldn't be stand-alone.
To minimise the number of ports used vs. the original code, only RX/TX are used. The rest are just wired to VCC. You'll have to modify your setup accordingly.
It's really simple to use.
begin(rxPort, txPort, baudRate) that'll setup the serial port to communicate with the device, any standard digital port is fine.
requestMeaurement() - Send the distance request command. It'll only ever allow you to request it once until a message has been received regardless of the times you call the method.
hasReading() avoids blocking, it checks until the serial buffer has sufficient data.
...and finally, getDistance(). This returns an integer.
Please find the library at:
http://download.milesburton.com/Arduino/URM37/URM37_2.0.zipAnd the manual:
http://www.milesburton.com/wiki/index.php?title=URM37_Ultrasonic_Distance_Measurement_Library