Circle and its applications

Preparing For This Tutorial:

  • The LEGO Mindstorm EV3 Robot that coincides with this tutorial comes from building specific sections found in the LEGO Mindstorm Education Core Set building instructions (I’ll refer to use the Base model).

  • Lessons: Basic - Motors, Gyro sensor and geometric figures

Time constraints:

  • starting from 45 min - single lesson


Create a program that will make the robot run around the circumference of: an equilateral triangle, a square, a pentagon and other polygons.


In order to define the robot’s trace as a triangle or any n-angle, from a mathematical point of view, firstly the robot determines the segment and next it turns by a certain angle. This task should be repeated for the appropriate number of times according to the drawn geometric figure.

Firstly, we’ll check how to draw for example a 30-centimeter segment (the length of course depends on you). We need to know how many turns the wheel should make.

Circumference - the distance around the edge of a circle. To calculate the circumference of a circle, use the formula \(C\ = \ \pi d\), where C is the circumference, d is the diameter, and \(\pi\) we put 3.14. Using this formula we can write that

\(30\ cm\ = \ \text{πdx}\) (1)

where \(x\) is a number of rotation of robot’s wheel, \(d = \ 5.6\ cm\)(diameter of robot’s wheel) and \(\ \pi = 3.14\), so it is easy to compute \(x\).

You have all information necessary to write the first part of the programme.

Now we will investigate the second part i.e. turn by a certain angle. One wheel of the robot doesn’t turn. We need to calculate how many turns the second robot’s wheel should make.

A circle is 360° all the way around; therefore, if you divide an arc’s degree measure by 360°, you find the fraction of the circle’s circumference that the arc makes up. Then, if you multiply the circle’s circumference by that fraction, you get the length along the arc. Formula is

\(arc\ length\ = \ 2\ \pi\ R\ (\ \theta\ /360\ )\),

where \(R\) equals to the radius of the circle and \(\theta\)- equals the measurement of the arc’s central angle, in degrees. Note, \(R\) is not the radius of the robot’s wheel, it is the radius of the wheel whose fragment is delineated by the robot during the turn (so there is - Wheel track - means the shortest distance between the center of the tire treads on the same axle).


The robot wheel moves on this arc. It travels a path whose length is equal to \(arc\ length\ = \ \pi dx\) where \(x\) is the number of rotation of robot’s wheel, \(d\) is the diameter of robot’s wheel and \(\pi = 3.14\).

It is known that diameter is equal to radius multiplied by 2. Let denote by r radius of robot’s wheel, so \(arc\ length\ = \ 2\ \pi\ r\_ w\ x.\)Comparing both formulas we get

\(2\ \pi\ R\ (\ \theta\ /360\ )\ = \ 2\ \pi\ r\ x\),


\(x = \ (R\ /\ r)\ (\ \theta\ /360\ )\),


\(r\)is radius of robot’s wheel

\(\text{R }\)is radius of the wheel whose fragment is delineated by the robot during the turn (robot’s wheel track)

\(\theta\)- equals to the measurement of the arc central angle, in degrees

\(x\) is the number of rotations of the robot’s wheel.

Note. Modify your programme - assume that one wheel turns left, and second turns right.

Step 3. Create a programme to make the robot draw an equilateral triangle, square, regular pentagon, etc. The input will be the number of angles, so we have to compute the measure of the one angle in the figure (for details see lesson Gyro and geometric figures) .

Short help on programming

Commands/functions needed for the exercise

Import necessary library

#!/usr/bin/env python3

from ev3dev2.motor import MoveTank, OUTPUT_B, OUTPUT_C

create a new instance of the class and pair the motors


Rotate the motors at left_speed and right_speed for rotations. Left_speed and right_speed are integer percentages of the rated maximum speed of the motor. on_for_rotations(left_speed, right_speed, rotations, brake=True, block=True)

If left_speed is not equal to right_speed (i.e. the robot will turn), the motor on the outside of the turn (the one with the faster speed) will rotate for the full rotations while the motor on the inside will have its number of rotations calculated according to the expected turn.

Next Section - Circle measure the distance