Hi,
I added a line what I like to have is to sign the distance to U i, i = 0, 1, 3, how should I do it please?
Thanks
Adam
#include <NewPing.h>
#define SONAR_NUM 3 // Number of sensors.
#define MAX_DISTANCE 200 // Maximum distance (in cm) to ping.
NewPing sonar[SONAR_NUM] = { // Sensor object array.
NewPing(10, 11, MAX_DISTANCE), // Each sensor's trigger pin, echo pin, and max distance to ping.
NewPing(12, 13, MAX_DISTANCE),
NewPing(8, 9, MAX_DISTANCE)
};
uint8_t currentSensor = 0;
uint8_t U = 0;
unsigned int cm[SONAR_NUM];
void setup() {
Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}
void loop() {
for (uint8_t i = 0; i < SONAR_NUM; i++) { // Loop through each sensor and display results.
delay(50); // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
///// Serial.print("U");
Serial.print(i);
Serial.print("=");
Serial.print(sonar[i].ping_cm());
Serial.print("cm ");
Ui = sonar[i].ping_cm();
}
Serial.println();
}
ERROR:
Arduino: 1.8.3 (Windows 7), Board: "Arduino/Genuino Uno"
C:\Users\HUA.DELLV-PC\Documents\Arduino\newping.1\newping.1.ino: In function 'void loop()':
newping.1:35: error: 'Ui' was not declared in this scope
Ui = sonar[i].ping_cm();
^
exit status 1
'Ui' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.