Turning the mBot by gyro-control
The aim was to turn mBot for a specific angle, e.g. 90°.
Turning the bot by driving the motors for a specific time and power is very inaccurate, because of different friction of the ground and capacity of batteries.
A good solution is to use a gyro-sensor and to integrate the angle-velocity over the time until the specified angle is reached.
The Me-3-axis-Gyrosensor can use to do this job.
Get sure, that you use the z-axis to get the right turning angle!
I got best results, when I determined an angle of less 5 degrees, e.g. for a wished 90° turn I gave it 85°.
I think it’s because of the inertia of mass and slipperyness of ground.
You can download Arduino-program under the following link:
Get sure, that the ports of motors and gyro sensor in the program correspond to your mBot configuration.
Have fun!
Sigtrygg