My program moves an ultrasonic sensor around 260 degrees and the values are recorded down in an array variable every 2 degrees it turns. It moves back and measure it 3 more times, storing each measurement in a different array variable (in total there are 4 array variables).
I want to get the average value from the four array variable thus I use the 'read at index' mode of the array operations.
It uses the loop index to get the index of the arrays. Then it takes the values and calculates the average before putting them in another variable array. However, the brick shows an error message right after the ultrasonic sensor is finished measuring.
I removed some parts of the program in order to find the cause of the error and I found that it might have something to do with the loop index. It might also have been because the array is not found. I tried using another variable that adds one every loop and then uses it to get the index but the message would appear.
I am not sure why there is the error, nothing contradicts the program, there is no math error, it should have worked. I hope you guys can tell me why this happens and how to solve it. Thank you!
Here is the complete program: Clarifications It loops 130 times as the ultrasonic sensor measures every 2 degrees it turns, so if it turns 260 degrees, there will be 130 measurements, 130 values in the arrays.