7. Case 06: Drive at Random

7.1. Purpose


  • Programme to set the TPBot driving at random.

7.2. Material


../../_images/TPBot_tianpeng_case_01_01.png

7.3. Software


MicroSoftmakecode

7.4. Programming


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

../../_images/TPBot_tianpeng_case_01_02.png

  • We need to add a package for programming. Click “Extensions” in the bottom of the drawer and seach with “tpbot” in the dialogue box to download it.

../../_images/TPBot_tianpeng_case_01_03.png

##Sample

  • Set a smile face on the micro:bit.

  • Set the speed of the left and the right wheel at a random value between -100~100 and pause 2 seconds.

../../_images/TPBot_tianpeng_case_06_04.png

7.5. Conclusion


  • The micro:bit shows a smile face and the speed of both wheels changes every two seconds at random.

7.6. Exploration


7.7. FAQ


7.8. Relevant File