15. Case 14: Remote Control with Joystick:bit

15.1. Purpose


  • Programme to control the TPBot with the Joystick:bit.

15.2. Material


../../_images/TPBot_tianpeng_case_01_01.png

15.3. Software


MicroSoftmakecode

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

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

../../_images/TPBot_tianpeng_case_14_03.png

##Sample

Remote Control Part

  • Set the radio group as 1.

  • Judge the value of x&y of the Joystick in the forever brick, if the value of the x is below 200, radio send number 4; if the value of the x is over 800, radio send number 3; if the value of the y is below 200, radio send number 2; if the value of the y over 800, radio send number 1; or radio send number 0.

../../_images/TPBot_tianpeng_case_14_04.png

Link

--- ## Conclusion ---
  • The movement of the TPBot is controlled via the Joystick:bit.

15.5. Exploration


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

15.7. Relevant File