Case 18 - Codey Rocky avoids obstacles

Part 1   Objective

Make Codey Rocky turn left or right when it encounters an obstacle and move forward after it passes the obstacle.

78.gif

Part 2   Preparation

  • Assembled Codey Rocky x 1

  • USB cable x 1

  • Computer with network access x 1

Connect Codey to the computer by using the USB cable, open mBlock 5 (PC client or web version), delete the default device, click +add, select Codey from the Device Library and then click Set as mostly used device in the upper left corner, click Connect, and select the Upload mode.

79.gif

80.gif

Part 3   Programming

Turn the IR color sensor at the bottom of Codey Rocky to be at the front of it. Use Action blocks, Control blocks and Sensing blocks, and click Upload to make Codey Rocky start moving forward when you press button A, turn left or right randomly when it encounters an obstacle, and move forward after it passes the obstacle.

81.gif

Part 4   Practice

Make a track with multiple obstacles on and let Codey Rocky pass the obstacles.

Was this article helpful?
4 out of 5 found this helpful

Comments

0 comments

Please sign in to leave a comment.