A Toolkit To Learn Algorithmic Thinking Using MBot Robot
A Toolkit To Learn Algorithmic Thinking Using MBot Robot
Abstract: We propose a new toolkit to help children at elementary or secondary school to learn algorithmic thinking through
mBot robot programming in this paper. The toolkit also helps people teaching children such as teachers and parents. The
toolkit is composed of four types of related elements: specification, mBot hardware component, algorithm, and Scratch code. A
toolkit user can understand the robot’s behavior through the algorithm and specification even if they do not know Scratch
programming language and can convert each step of an algorithm to a sequence of Scratch code. The toolkit also provides a
library for the users to create a new mBot application and associated algorithm and code.
Then an algorithm and the corresponding code can be a good 2. Initialize variables
sample to develop algorithm and program that the user wants. 3. Wait until the on-board button is pressed
A user can start developing a scratch code by considering 4. Repeat the following steps 4 times
algorithm. The algorithm can be easily converted to a scratch 4.1 Move forward to the indicated distance (10cm)
code as long as the algorithm follows certain guidelines 4.2 Turn Right at an angle of 90 degrees
described in Section 3.3. The activity of understanding,
The above algorithm contains basic operations of the motor
searching and reusing the toolkit elements will naturally develop
device. The correspondence between the device and basic
ability of algorithmic thinking of the user. Since an algorithm is
operation is represented in Table 1, Such representation of mBot
simpler than the corresponding scratch code, a user can make
hardware devices and basic operations can be converted into the
challenge to a more complex program. This implies that
building blocks of a program for mBot.
algorithmic thinking will facilitate creativity of the user.
3.3 Algorithm Guidelines Table 1 Mapping of Device and Basic Operation for Rectangle Drawing
Our algorithm guidelines are defined based on the guidelines Device Basic Operation
defined by Steve McConnell [4]. 4.1 Move forward to the indicated distance
An algorithm is a sequence of steps. Each step is either a Motor (10cm)
basic operation, a routine call (high level operation), a 4.2 Turn Right at an angle of 90 degrees
conditional statement or an iterative statement. Each step must
clearly describe intention of the step. Each basic operation 4.1.3 Scratch Code
must correspond to an mBot hardware component. Each routine Each step of the algorithm described in Section 4.1.2
call must correspond to a subroutine and each subroutine must corresponds to a sequence of scratch code as illustrated in Table
correspond to a single high-level operation. Each sequence of 2. The entire program is represented in Figure 6. The blue
conditional statements must cover all possible cases. An ‘define’ block is used to define a subroutine. The ‘Initialize’,
iterative statement must clearly describe the operations or the ‘stop’, ‘turnRightby’ and ‘moveFoward’ are the procedures to
processed data at each iteration. control the motors on mBot robot by initializing variables for
the calculation of the Motor value. The readers can observe
4. Detailed Explanation of Toolkit Element
that each scratch code corresponds to exactly one algorithm
We developed a rich set of mBot toolkit using mBlock and step.
run on mBot robot as listed below. We shall demonstrate some
of them in this section.
Basic Code to Understand Each Code Block in mBlock
Rectangle Drawing
Hexagon Drawing
Circle Drawing
Pentagon Drawing
Obstacle Detection
Line Tracing
Dancing Robot with Light Sensor
Two mBot Robots Run in a Relay Race
Six-legged Beetle Robot Figure 6 Scratch Code: Rectangle Drawing
Six-legged Mantis Robot
Six-legged Crazy Frog Robot Table 2 Mapping between Basic Operation and Scratch Code
Detecting Motion Around the Robot Basic Operation Scratch Code
Control Robot’s Speed with Potentiometer 1. Wait until the
Basic Code to Get Potentiometer Value green flag is
Basic Code to Get Joystick Value clicked
Basic Code to Get Light Sensor Value 2. Initialization
Basic Code to Get Seven Segment Value variable
Basic Code to Get Motion Sensor Value
Basic Code to Get RGB LED Value
Basic Operation Scratch Code Table 3 Mapping of Device and Basic Operation for Obstacle Detection
4. Repeat the Device Basic Operation
following steps 4 3.1 Read ultrasonic sensor value to identify the
times Ultrasonic distance to an obstacle
Sensor 3.3 If the detected distance is less than 10cm,
then do the following steps
4.1 Move 3.2 Run Forward
forward to the 3.3.2 and 3.3.3.2 Move Forward to 10cm
Motor
indicated 3.3.1 and 3.3.4 Turn Right at 90 degrees
distance (10cm) 3.3.3.1 Turn Left at 90 degrees
Table 4 Mapping of Device and Basic Operation for Line Tracing Table 5 Value of the Line Tracer Sensor
Device Basic Operation Value State Description
1.1.2.2 Turn the LED to red 0 Line follower is on the line
1.1.3.2 Turn the LED to green 1 Line follower is on the right side of the line
LED
1.1.4.2 Turn the LED to blue 2 Line follower is on the left side of the line
1.1.5.2 Turn the LED to white 3 Line follower is not on the line
1.1.1 Read line follower value
4.4 Six-legged Beetle Robot
1.1.2 If the line follower is on the line, then
4.4.1 Specification
do the following steps
This program is to control Six-Legged Beetle Robot run
Line 1.1.3 If the line follower is on the right side
forward and run backward which controlled by IR Remote
Follower of the line, then do the following steps
controller (Figure 9).
Sensor 1.1.4 If the line follower is on the left side of
the line, then do the following steps
1.1.5 If the life follower is outside of the
line, then do the following steps
IR Remote 1.1 If IR remote A key is pressed, do the
Controller following steps
1.1.2.1 Go straight
1.1.3.1 Turn left
Motor 1.1.4.1 Turn right Figure 9 Six-legged Beetle Robot
1.1.5.1 Go backward
4.4.2 Algorithm Description
1.2 Otherwise the Robot will stop
1 Repeat the following step forever
1.1 If IR remote “up arrow” key is pressed, do the following
steps.
1.1.1 Turn the LED to red
1.1.2 Turn the left wheel with speed 255
1.1.3 Turn the right wheel with speed 255
1.2 Otherwise do the following steps
1.2.1 If IR remote “down arrow” key is pressed, do the
following steps.
1.2.1.1 Turn the LED to green
1.2.1.2 Turn the left wheel backward with speed 255
1.2.1.3 Turn the right wheel backward with speed 255
1.2.2 If IR remote “A” key is pressed, do the following
steps.
1.2.2.1 Turn the LED to blue
1.2.2.2 Stop turning the left wheel
1.2.2.3 Stop turning the right wheel
Figure 8 Scratch Code Line Tracer Table 6 Mapping of Device and Basic Operation for Six-Legged Beetle
Robot
4.3.3 Scratch Code Device Basic Operation
The entire program is represented in Figure 8. In this case 1.1.1 Turn the LED to red
the blue ‘define right(number1)’ has function to set Motor M2 LED 1.2.1.1 Turn the LED to green
speed. ‘Right’ is the name of variable and ‘number1’ is a 1.2.2.1 Turn the LED to blue
parameter. Then, if variable ‘right’ is called, it will set the Motor 1.1.2 Turn the left wheel with speed 255
corresponds to a sequence of scratch code and the entire 2 states in each iteration. For the detailed, see the state
program is represented in Figure 12. transition diagrams (Figures 13 and 14).
Table 8 Mapping of Device and Basic Operation for Two mBot thinking because the children are required to solve the puzzle in
Robot in a Relay Race the form of a computer program. Compared to these works,
Device Basic Operation our toolkit focuses on algorithmic thinking by providing a
4.2 Move forward to 10 cm collection of specifications, algorithms and scratch programs as
Motor
4.3 and 4.5 Turn 180 degrees demonstrated in Section 4.
Ultrasonic 4.4 Wait until there is an obstacle within 8cm 7. Concluding Remarks
Sensor
We proposed a toolkit to teach algorithmic thinking for mBot
Line 3 and 4.6 Follow the line until there is an
robot programming in this paper. The toolkit is composed of
Tracer obstacle within 8cm
specification, basic mBot operations, algorithm, scratch
Sensor
programs and a set of relationships among them. We
IR Remote 1. Wait until IR remote “A” key is pressed
demonstrated the effectiveness of the toolkit using various
Controller
examples. The concept of our toolkit can also be utilized to a
robot programming other than mBot. This indicates generality
4.6.3 Scratch Code
of our approach.
Figure 15 implements the algorithm for the first mBot. The
Currently the only problem is that the toolkit is described only
scratch code for the second mBot can be developed similarly.
in English so that there is a language barrier for most of the
5. Preliminary Evaluation Japanese secondary school students. We are planning to
develop a Japanese version of the toolkit as a future work for
We asked for a review of our toolkit to a secondary school
evaluation at an actual class.
teacher teaching computer programming and a university
professor who is an advisor of the teacher. They said that it is Acknowledgment
important to present couple of examples to the students which We appreciate Professor Sumi Kazuhiro at Faculty of
represent intermediate concept between program and Education, Saga University and Ms. Nishiyama at Jonan Junior
specification as well as basic operations of mBot hardware and High School for the preliminary evaluation of our toolkit.
sample programs. Then secondary school students will
Reference
understand and utilize the toolkit to create new application. [1] “Arduino Home Page”.
They evaluated sample algorithms defined in the toolkit is https://www.arduino.cc/en/Guide/Introduction, (accessed on
appropriate as such intermediate concept. They also 2018-01-11).
mentioned that the description of sample algorithms should be [2] Curtis, S., “Two thirds of parents 'don't know what an algorithm
flexible enough so that students can develop various new is'”,
algorithms without too much restriction of the description style. http://www.telegraph.co.uk/technology/news/11068502/Two-thirds
-of-parents-dont-know-what-an-algorithm-is.html, 2014-09-02,
6. Related Work (accessed on 2018-02-05).
[3] Liao Y., Zhao T., “mBlock Kids maker rocks with the robots”,
Although there is some work of computational thinking 2013”.
education, little is known about algorithmic thinking education. http://www.mblock.cc/edu/mblock-kids-maker-rocks-with-the-rob
Sullivan, A., et al. [6] proposed a computational thinking ots/, (accessed on 2018-01-11).
education utilizing playful learning with KIBO. The concept [4] McConnell, S,, “Code Complete”, Second Edition, Microsoft Press,
2004.
is: 1) algorithms, 2) modularity, 3) control structures, 4)
[5] Phetsrikran, T., Massagram, W., & Harfield, A., “First steps in
representation, 5) hardware/software, 6) the design process, and teaching computational thinking through mobile technology and
7) debugging. Through interlocking wooden programming robotics”, Asian International Journal of Social Sciences, 17(3),
blocks that contain no embedded electronics or digital 37-52, 2017.
components (KIBO), students can explore logical organization [6] Surllvan, A., Bers, M., Mihm, C., “Playing, and Coding with
and sequencing using the tangible programming blocks which KIBO: Using Robotics to Foster Computational Thinking in Young
Children”, in Proc. CTE 2017 (International Conf. on
they call algorithms.
Computational Thinking Education), pp. 110-115, 2017.
Phetsrikran, T., et al. [5] proposed the first step in teaching
[7] Teppattra, S., “What possibilities and hindrances do mathematics
computational thinking through mobile technology and robotics. and technology teachers express regarding teaching programming
This paper provides an application containing puzzles that have in compulsoryschool?”, Ämneslärarexamen, 225 hp,
different standard difficulty and topic in each level. Through Kompletterande pedagogisk utbildning, Ange datum för
this program can be installed on iPad and connected to a robot, slutseminarium 2017-03-20.
students must send a command and control the robots via [8] Wang Y., “Getting started with mblock, 2013”.
http://www.mblock.cc/docs/the-getting-started-guide/, (accessed
Bluetooth to solve the puzzle.
on 2018-01-11).
From our viewpoint, Sullivan, A., et al. [6] focus on
programming, not an algorithm, since they do not distinguish
algorithm and programming. Phetsrikran, T., et al. [5] try to
teach pure programming and do not teach computational