Skip to content

Latest commit

 

History

History
91 lines (47 loc) · 2.59 KB

TPBot_tianpeng_case_02.md

File metadata and controls

91 lines (47 loc) · 2.59 KB

Case 02: Light Control

Purpose


  • Programme to control the colour of the LED lights.

Material


Software


MicroSoftmakecode

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.

Sample A

  • The LED headlights are in black while on start, and the micro:bit shows an icon.
  • Press button A to make the LED headlights show red.
  • Press button B to make the LED headlights show blue.
  • Press button A+B to make the LED headlights show green.

Link

<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="https://makecode.microbit.org/#pub:_0RM5AJgos7C5" frameborder="0" sandbox="allow-popups allow-forms allow-scripts allow-same-origin"></iframe>

Conclusion

  • Control the colour of the headlights with the buttons.
  • Press button A to make the LED headlights show red.
  • Press button B to make the LED headlights show blue.
  • Press button A+B to make the LED headlights show green.

Sample B

  • While on start, set the micro:bit showing an icon and the LED headlights in red for 2 seconds and then turning off.

Link

<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="https://makecode.microbit.org/#pub:_P5cJ7oV1664J" frameborder="0" sandbox="allow-popups allow-forms allow-scripts allow-same-origin"></iframe>

Conclusion

  • The micro:bit displays an icon while on start and the LED headlights of the TPBot show white for 2 seconds and then turn off.

Exploration


FAQ


Relevant File