I wired the circuit and the exact code given on the following site.
It performs correctly, gives correct readings as long as I have Arduino connected to USB Power Supply. But the moment I connect it to 9V Battery, I get the below fixed reading.
Distance: 3247 cms Distance:1270 Inches
The problem seems strange. Could you please help me?
The problem is not strange at all. In fact it is very common when someone uses a tiny 9 volt battery, or connects it to the wrong pins. Perhaps a drawing of your connections using the 9 volt battery should be supplied.