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

teckel:

deverett:
I have 8 sonars on my robot, all SRF05 which I want to use in single pin mode. I'd be happy to test out a single pin version of the new library.

I attached the version of the library that works with only one pin to the message right before your post. Here's a link to that message (two links at the bottom of the message):

NewPing Library: HC-SR04, SRF05, SRF06, DYP-ME007, Parallax PING))) - v1.7 - #112 by teckel - Sensors - Arduino Forum

For testing, you may want to start with communicating directly to all the sensors without the rest of the bot sketch. I have a sample 15 sensor sketch that you could easily modify to test your 8 sensors. The sketch can be found here:

Google Code Archive - Long-term storage for Google Code Project Hosting.

For 8 sensors, you would change SONAR_NUM to 8 and the "sonar" array to only have 8 NewPing objects. To make them only use one sensor, simply make the trigger and echo pin numbers the same. For example:

NewPing sonar[SONAR_NUM] = {

NewPing(3, 3, MAX_DISTANCE),
  NewPing(4, 4, MAX_DISTANCE),
  NewPing(5, 5, MAX_DISTANCE),
... complete for rest of sensors ...




After the test is complete, you could then update your full bot sketch to work with the NewPing library. For a simple non-event-driven example of how to implement the NewPing library, see this very basic "hello world" sketch (again, make the trigger and echo pins the same for one pin wiring):

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

That is, unless your current bot sketch is already event-driven, in which case you may want to look more at the 15 sensor example sketch for how to implement it in your project.

Just so you know, I've tested this release with 5 sensors using only one Arduino pin each and it worked without a hitch. The only exception is the SRF06 which needed a 0.1uf cap across trigger and echo. So, if it works for 5 there's no reason it shouldn't work for 8 sensors.

Tim

Thanks Tim, I wasn't logged in before so I couldn't see the attachments. I'm currently rewiring with shielded cable to all the sensors so I hope to test the code late tomorrow. As you suggest it will be just the multi-sonar sketch trimmed down to 8.

I'll let you know the results.

Thanks again,
Dave Everett