16. Case 12-The precise treasure hunting XGO#

16.1. Introduction#

Hi guys,We all know that dogs have a very sensitive sense of smell. If we let dogs help us find things when we lose things, can we let XGO help us find treasures? This article is our idea of implementing, and welcomes the elves to have better methods.

16.2. Quick to Start#

Materials Required#

micro:bit XGO Robot Kit × 1

magnet × 1

Working Principle#

  1. The micro:bit has a compass sensor called a magnetometer that measures the magnetic field. It senses the Earth’s magnetic field, so you can use it as a compass.

  2. When using the micro:bit compass for the first time, it must be calibrated. A little game will appear on the screen, and you have to tilt the micro:bit to light up each LED, and it’s ready to use.

Hardware Connections#

Connect the micro:bit with the computer through the USB cable. I believe you are already very skilled.


16.3. MakeCode Programming#

Step 1#

Click ” Advanced“ in the MakeCode drawer to see more choices.


We need to add a package for programming. Click “Extensions” in the bottom of the drawer and search with “XGO” in the dialogue box to download it.


Note: If you met a tip indicating that some codebases would be deleted due to incompatibility, you may continue as the tips say or create a new project in the menu.

Step 2#

sample program#

Treasure Hunt XGO Program#


Link:Treasure Hunt XGO Program

You may download it directly below:

monitor program#


Link:monitor program

You may download it directly below:

Projects Display#

Relevant Questions#

Because the magnetic strength of different magnets is different, the magnetic data size used by the program in this lesson is only for reference, and the data should be adjusted appropriately according to the magnet you get.


What if there are two magnets that affect the induction of the XGO?