NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7

snailshoe:
I am having the same problem with two of my HC-SR04s. All I'm getting is a reading of 0cm regardless of what's in front of the sensor. These sensors both work with a different ultrasonic library. Does anyone have an idea of what may be causing this?

First, try using the example sketch below, it's the new example that's being included with NewPing. Be sure you have the trigger and echo pins wired correctly. Don't change anything in the example, even the pins used.

http://code.google.com/p/arduino-new-ping/wiki/Simple_NewPing_Example

Also, when you say you have a problem with two sensors, does that mean you have other sensors that work and two that do not? I've found the SR04 sensors tend to have a terrible quality control. Of the 4 that I have, only 1 I would say works correctly. The other 3 work, but get all wonky at distances beyond 50cm.

Finally, just to make sure we're both using the same library, attached is my development version of NewPing (v1.4 pre-release). Just replace these files with the ones already in the NewPing folder.

Tim

NewPing.h (7.57 KB)

NewPing.cpp (8.87 KB)