12. Case 09: Autonomous Obstacle Avoidance¶
The Cutebot avoids the obstacles automatically to move forward.
Click the “Advanced” to see more choices in the MakeCode drawer.
A codebase is required for Cutebot programming, click “Add Package” at the bottom of the drawer, search
Cutebotin the dialogue box and download it.
Note: If you met a tip indicating incompatibility of the codebase, you can continue with the tips or build a new project there.
Drag “go straight at full speed” brick into the
Sonarvariable to save the detected
Cmvalue in the
If the detected value is between
20which means there is obstacle being detected in the front 20cm far, set the left wheel speed to
0and right to
-50, make a right turn at a random time to complete an obstacle avoidance.
If not, move forward at its full speed.
The Cutebot moves forward at its full speed and will make a right turn to keep going if any obstacle being detected.
Why should the detected value be over 2cm ?