Ultrasonic sensor not responding

I had same problem with a HC-SR04 while constructing a simple robot using a L293d chip to drive 2 small DC MOTORS.

I kept getting

Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 1149cm
Ping: 0cm
Ping: 0cm
Ping: 0cm
Ping: 1149cm
Ping: 0cm

in the serial monitor.

The problem solved itself when I pinned the distance sensor directly to the 5 volt UNO pin. For some reason pinning the sensors Vcc pin to a positive hole in the breadboard which I connected to the 5 volt uno pin got the above results.

I am by no means an arduino expert but I suspect the UNO board has a voltage regulator that responds to the demand of the distance sensor.

Hopefully this will help someone.

Larry c