Problem with for loop
The motor should


  turn when the next average the program measures is 100 or more greater than the previous average it measured


So simply write it:

// Old average is called "average"
// Compute the new average and put it in next_average
if ((next_average - average) &gt;= 100)
{
  // Turn the motor
}
average = next_average;