Move along the M-shaped track

24,034
Author: Yisong Xu, Si Xu

Press the onboard button and mBot moves in a M-shaped track in the set order.

Hardware requirements:

mBot

Implementation:

Upload the program to Arduino

Example program download:

M-shaped track.sb2

download

Example programs
kids programming language

 

Script description

kids programming language To prevent mBot running after boot, use the onboard button as the start button. When the onboard button is pressed, the following script will be triggered.

 

Knowledge points
Point 1 How to make mBot move in a M-shaped track

Divide the track of mBot into 4 segments:
 Segment 1: Moving straight.
 Segment 2: Turning right and moving straight.
 Segment 3: Turning left and moving straight.
 Segment 4: Turning right and moving straight.
 Stop mBot by setting its forward-moving speed to 0.
kids programming language

By changing mBot’s speed in moving forward, turning left, turning right and its waiting time, the distance it moved and the angle it turned can be adjusted. Generally you need to try many times to get a proper angle. You should also consider conditions such as the ground it moves on and the motor power (electricity volume). Parameters in this example are for reference.

Point 2 How to get a proper value quickly
Taking “Segment 2: Turning right and moving straight” for example, place mBot on a white paper and enter an appropriate value, such as turning right for 1 second at 150 speed. Draw on the white paper the direction of mBot after its turning. If the angle is too big, you reduce the right-turning time; if too small, you increase the right-turning time. Repeat these steps and you can get a proper value.

 


Extended tasks

Task 1 Let mBot move in other tracks, such as a Z-shaped track.
Task 2 Add sound and light effects during mBot’s moving forward, such as lighting and honking during its turning.

 

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

—— More examples