unsigned long pingTimer[SONAR_NUM]; // Holds the times when the next ping should happen for each sensor.unsigned int cm[SONAR_NUM]; // Where the ping distances are stored.uint8_t currentSensor = 0; // Keeps track of which sensor is active.

void oneSensorCycle() { // Sensor ping cycle complete, do something with the results. for (uint8_t i = 0; i < SONAR_NUM; i++) { Serial.print(i); Serial.print("="); Serial.print(cm[i]); Serial.print("cm "); } Serial.println();}And all I get in output are zeroes. (0=0cm). I can hear it clicking but I'm beginning to think it may be defective. Any Ideas?

And all I get in output are zeroes. (0=0cm). I can hear it clicking but I'm beginning to think it may be defective. Any Ideas?

You have one sensor you're having a problem with, but you tried using the example sketch that's designed for 15 sensors using interrupts? Seems like if you're having a problem you should be starting with the basics. For example, use the Simple NewPing Example Sketch instead.

If that still doesn't work, you should do some basic troubleshooting. For example, try using different pings (the example sketch above uses pins 12 and 11, use those instead as you may have bad pins on your Arduino). If it still doesn't work, verify all your jumper cables are connected correctly (there's a diagram at the bottom of the above linked page). Next, replace your jumper wires with different ones. I've seen several times now where people are having a problem and they think their sensor is bad, only to find out that their jumper wires are broken (this is quite common).

One thing can be said for sure. If you use the NewPing library, use the example sketch linked above, use the exact pins in that sketch, and wire the sensor correctly, a good sensor WILL work in all cases.

Also, no reason to open a new thread with an ultrasonic sensor question, you can just ask on the NewPing thread if you're trying to get your sensor to work with NewPing.

Quite a bad sign. I cannot hear my (working) sensor and that's fine because the frequency is 40kHz, more than double of what a human ear is able to detect.

Even though they produce a 40kHz ping, you can still hear them click. Some are louder than others, but I can hear every one of my sensors if I get close enough (some are quite loud). We're not hearing the actual 40kHz ping, there's some type of vibration that's produced that's well within the human audible range. The clicking isn't even that high of a frequency either, it's probably close to 1kHz.

Thanks for the input, Tim. I tried the Simple Sketch mentioned in your last post with the same results- "Ping: 0cm". I double-checked my connections against the diagram using pins 11 and 12 for echo and trigger. Also, I have swapped jumper wires to no avail. Any other suggestions?

Quote

Also, no reason to open a new thread with an ultrasonic sensor question, you can just ask on the NewPing thread if you're trying to get your sensor to work with NewPing.

I feel kinda awkward hijacking a thread with my own personal problem. Time and again, I see moderators telling people to start a new thread.

Thanks for the input, Tim. I tried the Simple Sketch mentioned in your last post with the same results- "Ping: 0cm". I double-checked my connections against the diagram using pins 11 and 12 for echo and trigger. Also, I have swapped jumper wires to no avail. Any other suggestions?

That sketch using my 7 sensors all work perfectly. So, if you've discounted everything else, (not a pin, not a jumper wire, not a wrong connection, etc.) then it must be the sensor as the sketch and the library are known working. If you just can't get it working, I would like to have it. We hear all the time about sensors that don't work, but all that I have work without issue. My thought is that if I can find a unit that has a problem, I may be able to diagnose the problem and modify the library to work even with sensors that are on the fritz.

I received a new sensor in the mail today that works just fine. After comparing the two boards, I noticed that capacitor C12 is missing from the top right corner of the board. Any idea what a suitable value is for this capacitor?