@EngineerMike Debugging rubber duck you say… Looks like I need to find one of my teammates!
You shouldn’t be doing “=” to compare the sensor and desired value as if it overshoots by even 1 degree, it will turn forever
I see, what else can I use? I know you told me to use greater than, but I cant figure out how to implement it
There are a couple of ways to handle this.
- Look for the difference in the angle of the robot vs your target, and if it’s within a certain distance, exit. In other words, something like:
turnDifference = targetValue - currentValue
if((turnDifference < 2.0) OR (currentValue > targetValue)
motors.stop
(I realize that the above is not blocks code, but it’s pseudocode that you should be able to translate into blocks.)
- Look to see if the current value is greater than the target value.
if(currentValue > targetValue)
motors.stop
This method is less good, as your robot is going to end up past the desired point every time.
2 Likes