Hey there,
I'm building a football roboter and it should find the ir emitting ball, but I encountered a problem with reading the values. Due to the frequency of the ball the values read by the sensors aren't consistend.
Then I tried to collect 200 values and calculate the average value, but this process slows down the reading of the values massive. What else can I do?
Start by posting your current code
Well there is not relly a code worth to show you. The code with collecting 200 values and calculating the average is not doing more. Just adding the read value to a variable and after 200 iterations the value is then divided by 200
float value = 0;
int count = 0;
void loop(){
if(count < 200){
count++;
value += analogRead(A0);
}
else{
value /= 200;
count = 0;
}
}
but I think this is not a good solution, because it even slows the mega so much down that only every half a second the value is updated.(I need this for more than 5 sensors). is there maybe a better one?