6. Case 04: Run at Random

6.1. Purpose


  • Make your Cutebot move(move forward, reverse or change direction) as if in “his” mind.

6.2. Materials


6.3. Software Platform


MicroSoft makecode

6.4. Programming


Step 1

  • Click the “Advanced” to see more choices in the MakeCode drawer.

Step 2

  • Choose “show icon” in the On startbricks. https://raw.githubusercontent.com/elecfreaks/learn-cn/master/microbitKit/smart_cutebot/images/case_01_02.png

Step 3

  • Drag left_speed and right_speed bricks into forever brick to set a speed at random from -100 to 100 of the two wheels.

  • Assign the two variables of the speed to the left and right wheels.

https://raw.githubusercontent.com/elecfreaks/learn-cn/master/microbitKit/smart_cutebot/images/case_04_01.png

Programming

Links: https://makecode.microbit.org/_UFETasLycR3g

You can also download it directly below:

---

https://raw.githubusercontent.com/elecfreaks/learn-cn/master/microbitKit/smart_cutebot/images/cutebot-pk-1.png

  • A codebase is required for Cutebot programming, click “Add Package” at the bottom of the drawer, search Cutebot in the dialogue box and download it.

https://raw.githubusercontent.com/elecfreaks/learn-cn/master/microbitKit/smart_cutebot/images/cutebot-pk-11.png

Note: If you met a tip indicating incompatibility of the codebase, you can continue with the tips or build a new project there.

6.5. Result


  • 小车随机前进,后退或者转向。 The Cutebot moves forward, reverses or changes its direction at random.

6.6. Exploration


6.7. FAQ


6.8. Relevant Files