10. Case 06 -Use Joystick:bit to Control the XGO#

../../_images/xgo-6-1.png

10.1. Purpose#

Hello, in the first few lessons, we basically programmed the program first and then controlled the XGO movement, so we cannot control the XGO in real time. Then, in this lesson, we will realize the real-time control of the XGO through the remote control. Therefore, in this lesson, we will Implement Joystick:bit to control XGO to make actions. For related documents of joystick:bit, please refer to: Joystick:bit.

10.2. Materials#

1 × micro:bit XGO Robot Kit

1 × Joystick:bit

10.3. Working principle#

We use a data cable (USB cable) to connect the computer with the micro:bit

../../_images/microbit-xgo-robot-kit-22.png

10.4. Software Platform#

Makecode

10.5. MakeCode programming#


Step 1#

Click Advanced in MakeCode to see more options.

../../_images/microbit-xgo-robot-kit-10.png

For programming, we need to add a package: click “Extensions” at the bottom of the MakeCode drawer, and search for “XGO” in the dialog to download.

../../_images/microbit-xgo-robot-kit-11.png

Note: If you encounter a prompt that some codebases will be removed due to incompatibility, you can follow the prompt to continue or create a new project in the menu.

10.6. Code#

samples:#

Program the Joystick:bit#

../../_images/case06-01.png

Program XGO#

../../_images/case06-02.png

Link: Joystick program

Or you can download it directly:

Link: XGO Program

Or you can download it directly:

10.7. FAQ#

If XGO doesn’t walk, check the power status of the XGO and the Joystick:bit.

10.8. Exploration#

Can we control the XGO with the C/D/E/F buttons on the Joysitck:bit?