Okay, I have been frigging around with this stupid if statement which should not be a problem but cannot get it to work.
I am printing the variable out below and I get 179.00 at one point but the if statement does not work.
So what should happen is angle starts at zero and goes up by 17.9 until it reaches 179 at which point the flag flips the equation so that the system then counts down by 17.9 until it reaches zero however in one of my tries it went to -0.00 and kept going. what am I missing here?
After Calc: 179.00
Angle: 179.00
522 833 - 861 = -28
After Calc: 196.90
Angle: 196.90
angle = angle + (17.9 * looking);
Serial.print("After Calc: ");
Serial.println(angle);
if(angle == 179.00){ //If turned fully to the right, switch to looking left
looking = -1;
Serial.print("Looking Left");
}
else if(angle == 0.00){ //If turned fully to the left, switch to looking right
looking = 1;
Serial.print("Looking right");
}