Problem with for loop I'm having trouble with the syntax of code. I want to have the motor turn when the next average the program measures is 100 or more greater than the previous average it measured. I don't know how to write the if statement:

if(average == (average&gt;=100)) {
for(pos = 0; pos &lt;= 120; pos += 1) {
  sServo.write(pos);
  delay(50);
}
for(pos = 120; pos &gt;= 0; pos -= 1) {
  sServo.write(pos);
  delay(50);
}
}
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;