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

duxiaoshi:
thanks, teckel :slight_smile:
your code works well, no strange or negative value return.

This is my robot.

two sensor in the front, one in the back, two in the left and two in the right and two in each corner.
So it's 15 in all.

Now i'm working on how to avoid obstacle by these 15 sensors. I think the hard thing is how to combine these sensors data, and make decision to let bot run right way and avoid obstacle .

let the robot run autonomous and intelligent navigation is my final goal.( I have 9dof IMU sensor in bot and webcam in front to get the odometry data)

Glad to hear it works. With that many sensors, it's a prefect situation to see how low you could set PING_INTERVAL before you started getting cross-sensor echo. It should work if you change from 35ms to 29ms (which as a benefit also speeds up the total cycle time by 100ms). But, if you're creative with the sensor order, you very well could make this much shorter. For example, if the sensor ping order is on opposite sites of your robot where you're less likely to get an echo, you'll be able to set PING_INTERVAL lower without cross-sensor echo. With two sensors in opposite directions, I was able to get accurate results with a PING_INTERVAL of only 8ms! The advantage is that you could sample more frequently (about 8/second with 8ms interval instead of about 2/second with 35ms). The disadvantage would be less time to do other things, like process 9dof data. If the pings are in order around your robot, you probably cant get away with this as the adjacent sensor could get an echo from the previous sensor.

I've added the 15 sensors example sketch to the NewPing Wiki section for others that want to use a bunch of sensors and still have processing cycles to do other things.

Tim