Hey all, thanks for the replies.
The environment physically is a 3m x 3m room at the moment where i'm set up in a corner.
Electronically I'm set up with all power coming from the 5v on the arduino, that includes the 6 wires going to BW as descibed in this pdf
( http://www.maxbotix.com/documents/LV_Chaining_Constantly_Looping_AN_Out.pdf ) and the 6 wires going to PWR on the sensor. I feel sure that I must need more power here, as that seems like a huge ask on the arduino, to tie 6 logic pins high and run a current through 6 sensors to be measured. I'm just not sure how to do it.
I've been through my wiring and made sure that is all tight and neatly soldered everything in place to rule this out as a problem and I'm happy that the wiring (they call it daisy chaining) that I've done for the six sensors matches the recommendation. My code now looks like this:
int ultraSoundSignalPins[] = {0,1,2,3,4,5}; // 6 Ultrasound signal pins
int ultraSoundTriggerPin = 7; // output pin to start Ultrasound signals
int arraysize = 5; //quantity of values to find the median (sample size). Needs to be an odd number
int rangevalue[] = {0, 0, 0, 0, 0}; //declare an array to store the samples. not necessary to zero the array values here, it just makes the code clearer
void setup() {
Serial.begin(9600);
printArray(rangevalue, arraysize);
for(int i=0; i < 6; i++) {
pinMode(ultraSoundSignalPins[i], INPUT); // Switch signalpin to input
}
pinMode(ultraSoundTriggerPin, OUTPUT); // set this pin to output
//give the sensors time to boot up
delay(250);
// send RX pin high to signal to chain to ping
digitalWrite(ultraSoundTriggerPin, HIGH);
delayMicroseconds(30);
digitalWrite(ultraSoundTriggerPin, LOW);
pinMode(ultraSoundTriggerPin, INPUT); // electrically disconnects the pin
delay(50);
}
void loop()
{
unsigned long ultrasoundValue;
unsigned long echo;
delay(30);
for(int i=0; i < 6; i++)
{
for(int x = 0; x < arraysize; x++){
//Now the values from each sensor can be read:
rangevalue[x] = analogRead(ultraSoundSignalPins[i]); //Listen for echo
// Serial.println();
// Serial.print("UltraSound Value");
// Serial.print( ultraSoundSignalPins[i]);
// Serial.print( "= ");
// Serial.print(ultrasoundValue);
delay(30);
}
// Serial.print("unsorted ");
// printArray(rangevalue, arraysize);
// Serial.println();
// isort(rangevalue, arraysize);
// Serial.print("sorted ");
// printArray(rangevalue, arraysize);
// Serial.println();
// now show the medaian range
int midpoint = arraysize/2; //midpoint of the array is the medain value in a sorted array
//note that for an array of 5, the midpoint is element 2, as the first element is element 0
Serial.print("median range value for sensor ");
Serial.print(ultraSoundSignalPins[i]);
Serial.print(" : ");
Serial.print(rangevalue[midpoint]);
Serial.println();
}
Serial.println();
Serial.println();
}
//*********************************************************************************
// sort function
void isort(int *a, int n)
// *a is an array pointer function
{
for (int x = 1; x < n; ++x)
{
int j = a[x];
int k;
for (k = x - 1; (k >= 0) && (j < a[k]); k--)
{
a[k + 1] = a[k];
}
a[k + 1] = j;
}
}
//***********************************************************************************
//function to print array values
void printArray(int *a, int n)
{
for (int x = 0; x < n; x++)
{
Serial.print(a[x], DEC);
Serial.print(' ');
}
Serial.println();
}
and it returns these results currently. Certainly sensors 0-2 should be returning bigger values, I feel like the current running across the other sensors must be impacting on the ability of all sensors to read properly. The only true read in the set is probably that first reading on sensor 0 where it is bouncing back diagonally from the other side of the 3m room. All the sensors are pointing the same way and the environment for this read remained the same through out ( I triggered them with the mouse from the far corner and stood very still.)
median range value for sensor 0 : 394
median range value for sensor 1 : 101
median range value for sensor 2 : 101
median range value for sensor 3 : 103
median range value for sensor 4 : 43
median range value for sensor 5 : 33
median range value for sensor 0 : 184
median range value for sensor 1 : 99
median range value for sensor 2 : 99
median range value for sensor 3 : 101
median range value for sensor 4 : 41
median range value for sensor 5 : 33
median range value for sensor 0 : 166
median range value for sensor 1 : 101
median range value for sensor 2 : 99
median range value for sensor 3 : 101
median range value for sensor 4 : 43
median range value for sensor 5 : 33
median range value for sensor 0 : 155
median range value for sensor 1 : 99
median range value for sensor 2 : 99
median range value for sensor 3 : 99
median range value for sensor 4 : 41
median range value for sensor 5 : 35
median range value for sensor 0 : 169
median range value for sensor 1 : 101
median range value for sensor 2 : 99
median range value for sensor 3 : 94
median range value for sensor 4 : 41
median range value for sensor 5 : 33
median range value for sensor 0 : 183
median range value for sensor 1 : 99
median range value for sensor 2 : 99
median range value for sensor 3 : 101
median range value for sensor 4 : 41
median range value for sensor 5 : 33
median range value for sensor 0 : 178
median range value for sensor 1 : 101
median range value for sensor 2 : 101
median range value for sensor 3 : 101
median range value for sensor 4 : 43
median range value for sensor 5 : 35
m