Ultrasonic range sensor not working correctly with Nano

I came across this issue with my recent project. The issue was actually happening only when I power the nano from USB. This is a Power issue. I powered Nano with a battery (6 - 9v is enough) and it started work fine.