6. Case 05: Automatic Lamp

6.1. Purpose


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

6.2. Material


../../_images/TPBot_tianpeng_case_01_01.png

6.3. Software


MicroSoftmakecode

6.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 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.

../../_images/TPBot_tianpeng_case_05_04.png

6.5. Conclusion


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

6.6. Exploration


6.7. FAQ


6.8. Relevant File