Skip to main content

Remote Control with Joystick:bit

Purpose


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

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.

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

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.

Receiving Part

  • Set the radio group as 1.
  • Save the received number as the variable in "on radio received..."block.
  • Judge if the value is 1, if yes, set the TPBot moving forward at the speed of 100%; if it's 2, set the TPBot reversing at the speed of 50%; if it's 3, set the TPBot turning left at the speed of 50%; if it's 4, set the TPBot turning right at the speed of 50%; If it's 0, set the TPBot to stop.

Conclusion

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

Exploration


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.

Relevant File