Now you should develop a program to make the motor reach the required position.
Now you should develop a program to make the motor reach the required position.
Let’s expand the table we have already discussed by including information about the position in degrees at which the motor was, the degrees at which it should rotate and its position in degrees in the end. Do you notice anything?
If you subtract the degrees at which you want the motor to be from the degrees at which the motor was, you will get the degrees at which you should rotate the motor. Or:
Degrees of rotation = new position in degrees – previous position in degrees
We show that in the following program:
The first block reads the current position of the motor in degrees. Then you subtract it from the number below a, which is the required position. As a result, you get the degrees which the medium motor should rotate.
Combine the upper two blocks in a MyBlock, so that when you input the required position in degrees, the motor will rotate the necessary number of degrees.