The ‘ball angle’ block (Sensors) is used to get a measurement of angle, between -180 and +180. If the ball is on the left of the robot, the number is negative. If the ball is on the right, the ball is positive.
Let’s write a program that will rotate the robot to face the ball.
We have three conditions:
We’re using -20 and 20 degrees because the robot can’t stop instantly.
Let’s start with the if. Here, we drag the if and comparison blocks, and we can also press the + to get the ‘else if’ section.
Now we just need to add the motor movement.