Report back: Success!!! I tried your sample sketch on IDE 23 and 1.0. I got an error with 23, it said it could not find NewPing.h. I then put the same library and sketch into 1.0 and it compiled fine. Next, I modified the sketch to print the output from the sensors and also added a delay to slow the data to a readable level.
Here is the modified sketch that I tested with my 2 sensors.
#include <NewPing.h>
NewPing sonar1(12, 13, 200); // Sensor 1: trigger pin, echo pin, maximum distance in cm
NewPing sonar2(10, 11, 200); // Sensor 2: same stuff
#define pingSpeed 100 // Ping frequency (in milliseconds), fastest we should ping is about 35ms per sensor
unsigned long pingTimer1, pingTimer2;
void setup() {
Serial.begin(9600);
// Do other stuff here
pingTimer1 = millis() + pingSpeed; // Sensor 1 fires after 100ms (pingSpeed)
pingTimer2 = pingTimer1 + (pingSpeed / 2); // Sensor 2 fires 50ms later
}
void loop() {
if (millis() >= pingTimer1) {
pingTimer1 += pingSpeed; // Make sensor 1 fire again 100ms later (pingSpeed)
int in1 = sonar1.ping_in();
Serial.println(in1);
}
if (millis() >= pingTimer2) {
pingTimer2 = pingTimer1 + (pingSpeed / 2); // Make sensor 2 fire again 50ms after sensor 1 fires
int in2 = sonar2.ping_in();
Serial.println(in2);
// Both sensors pinged, process results here
}
delay(1000);
// Do other stuff here, notice how there's no delays in this sketch, so you have processing cycles to do other things :)
}