12. Case 09: Seeking light#

12.1. Purpose#

  • Programme to set the TPBot heading to the light.

12.2. Material#


12.3. Software#


12.4. Programming#

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


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



  • Set the headlights in white in the on start brick.

  • Judge if the light intensity is over the set point in the forever brick, if yes, set the TPBot moving forward; or it goes around in circles.



  • Power up to set the TPBot going around in circles or moving forward if the detected light intensity is over the set point.

12.5. Exploration#

12.6. FAQ#

Q: The car does not work with the code in the wiki.
A: It should be the batteries that are lack of power, please try to fix it by adding the value of the speed in the code.

12.7. Relevant File#