Problem with ultrasonic sensor

out of curiosity what kind of sensors are you using? I've had good luck with SRF04 and MaxSonar EZ1 but i know someone who was using the sensors that come out of car bumpers and his board would freeze up randomly (have to turn off power and reset) , after a couple hours of tweaking we got it working pretty well but discovered that when the sensor reported a 0 that it would freeze up. My theory is that the pulse is coming back to quickly and screwing up the transistor circuit he was using to drive and read the sonar pin or its overflowing an internal timing register in the atmega. It's strange i've only ever seen this happen once and your post reminded me of it.

I'm working with a few SRF04's right now for a robotics competition and i have 6 wired up and running just fine on one board. I even put an obstacle right on the sensors with no problems. It may help to add a small delay at the end before the return. I started with delay(500) when i first wired everything up, that let me watch the values and put a hand in front of each and watch for a change. I dropped it down to 10 currently for some testing and i'm sure it can go even lower but all of the serial printing faster then that would crash the terminal. Once i'm ready for a real test i'll drop it to either 1ms or go down to the microseconds.