8. Case 05: Automatic Lamp#

8.1. Purpose#

  • Programme to turn on the lights automatically in the darkness.

8.2. Material#


8.3. Software#


8.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 to move forward at the speed of 100%.

  • Judge if the current light intensity is below the set point, if yes, set the headlights in white; or in black.



  • Power up to set the TPBot driving forward and turning on/off the headlights automatically while it goes into the dark/bright area.

8.5. Exploration#

8.6. FAQ#

8.7. Relevant File#