if statement breaks loop

I am making code for six sensors and basically want to calculate the std deviation for each of the sensors. If any of the sensors gets above a value (1.29), then it will note which sensor it is and eventually light a corresponding led. However, when i add the if statement below, the void loop breaks and it doesnt even print out the std deviation value right above it. Do any of you notice any problems? Thank you.

``````unsigned long starttime;
unsigned long endtime;

const int analogOutPin = 9;

int sensorValue = 0;
int outputValue = 0;

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println("Begin");
int arr1[200];
int arr2[200];
int arr3[200];
int arr4[200];
int arr5[200];
int arr6[200];
int i = 0;
starttime = millis();
endtime = starttime;
while (((endtime - starttime) <=10000) && (i < 200)){
arr1[i] = sensorValue1;
arr2[i] = sensorValue2;
arr3[i] = sensorValue3;
arr4[i] = sensorValue4;
arr5[i] = sensorValue5;
arr6[i] = sensorValue6;
endtime = millis();
i++;
}
long sum1 = 0;
long sum2 = 0;
long sum3 = 0;
long sum4 = 0;
long sum5 = 0;
long sum6 = 0;
for (i = 0; i < 200; i++)
{
sum1 = sum1 + arr1[i];
sum2 = sum2 + arr2[i];
sum3 = sum3 + arr3[i];
sum4 = sum4 + arr4[i];
sum5 = sum5 + arr5[i];
sum6 = sum6 + arr6[i];
}
float average1 = sum1 / 200.0;
float average2 = sum2 / 200.0;
float average3 = sum3 / 200.0;
float average4 = sum4 / 200.0;
float average5 = sum5 / 200.0;
float average6 = sum6 / 200.0;

float std1 = 0;
float std2 = 0;
float std3 = 0;
float std4 = 0;
float std5 = 0;
float std6 = 0;
for(i=0; i<200; i++){
std1 += pow(arr1[i] - average1, 2);
std2 += pow(arr2[i] - average2, 2);
std3 += pow(arr3[i] - average3, 2);
std4 += pow(arr4[i] - average4, 2);
std5 += pow(arr5[i] - average5, 2);
std6 += pow(arr6[i] - average6, 2);
}
std1 = sqrt(std1/200);
std2 = sqrt(std2/200);
std3 = sqrt(std3/200);
std4 = sqrt(std4/200);
std5 = sqrt(std5/200);
std6 = sqrt(std6/200);
Serial.println(std1);
if ((std1 > 1.29) || (std2 > 1.29) || (std3 > 1.29) || (std4 > 1.29) || (std5 > 1.29) || (std6 > 1.29)){
float minimum = average1;
int o = 1;
if (average2 < minimum){
minimum = average2;
o = 2;
}
if (average3 < minimum){
minimum = average3;
o = 3;
}
if (average4 < minimum){
minimum = average4;
o = 4;
}
if (average5 < minimum){
minimum = average5;
o = 5;
}
if (average6 < minimum){
minimum = average6;
o = 6;
}
Serial.println(o);
}

}
``````

int[200] is 400 bytes. 400 * 5 = 2000 bytes.
which mcu you use?

Do any of you notice any problems?

Apart from the one noted above, I can think of simpler ways of squaring a number than this`std1 += pow(arr1[i] - average1, 2);`