Move along the S-shaped track

PRIMARY EDUCATION

Grade Level

COMPUTER SCIENCE

Subjects

mBot

Product

40MINS

Estimated duration
Longer description

Hardware requirements:

mBot

Implementation:

Upload the program to Arduino

Example programs

In this example the module directive  is defined to let mBot move in a S-shaped track.
Define the module directive to combine several blocks. The program executes the defined module directive, i. e. calling its defined block behavior. This can make the program simpler and easier to read. See Knowledge Point 2 for methods.

 

Knowledge points
Point 1 Use “differential speed” to control mBot’s turning.
Use Block  to directly control the direction of mBot in Example 15 Moving along the M-shaped track. Otherwise you can also control the speed of mBot’s left and right motors to control its direction:
When the right wheel speed is more than the left one, mBot turns left; when the left wheel speed is more than the right one, mBot turns right.
Install mBot correctly as required in the Instructions. Left wheel motor is connected to Motor Port 1 and right wheel motor to Motor Port 2. Watch mBot’s turning by testing the following script (taking mBot’s left turning for example, and its right turning is the same).

Script Turning
Turning left while moving forward
Turning left on the left wheel
Turning left on the right wheel
Turning left in place. The effects is the same with Block 

 

Point 2 How to define the module directive
Click “Data and blocks” in “Scripts” and click “Make a block ” and enter the name of the new module directive in the window poping up, and then clck “Ok”. Then define the module directive in the programming area to use the new module directive for programming.

 

Extended tasks

Task 1 Let mBot moves in a round track
Task 2 Modify the speed value of left and right motors of mBot (such as increasing the difference between the two values) and watch the moving status of mBot and record it.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.