Welcome to K230 Vision Module repository
15.microbit_k230 target tracking
microbit_k230 target tracking
microbit_k230 target trackingK230 and microbit communication1. Experimental Prerequisites2. Experimental wiring3. Main code explanation4. Experimental phenomenon
K230 and microbit communication
1. Experimental Prerequisites
This tutorial uses a micro:bit. The corresponding example program path is [14.export\microbit-K230\15.Microbit_k230_nano_tracker].
To begin the experiment, you must run the [14.export\CanmvIDE-K230\15.nano_tracker.py] program on the K230. We recommend downloading the program for offline operation.
Items needed:
Windows computer, microbit, USB to TTL module, K230 vision module (including TF card with image burned), type-C data cable, connecting cable (Dupont cable), alligator clip, import K230AI library: https://github.com/YahboomTechnology/K230-Module.git
2. Experimental wiring
| k230 vision module | Microbit |
|---|---|
| GND | GND |
| TXD(IO9) | P2 |
| USB to TTL module | Microbit |
|---|---|
| RXD | P1 |
| GND | GND |

3. Main code explanation
From the code, we can simply configure the serial port and call the relevant serial port and K230 building blocks to obtain data.
- x: The horizontal coordinate of the top left corner of the recognized box
- y: The vertical coordinate of the top left corner of the recognized box
- w: The width of the recognized box
- h: The height of the recognized box
If you want to open the source code of this tutorial, please drag the microbit source code corresponding to this tutorial into the makecode online programming webpage of the browser. The online programming website is: https://makecode.microbit.org/#
4. Experimental phenomenon
- After connecting the cables, the k230 visual module runs offline After K230 is connected to Canmv IDE, open the corresponding program, click [Save open script to CanMV board (as main.py)] on the toolbar, and then restart K230.

When the K230 is turned on, a green box will appear on the screen. Please aim the green box at the target to be tracked (using ultrasonic wave as an example here) and wait for a few seconds. When the green box turns red, it means the target has been detected. At this time, if you move the target object, you can see that the red box will move with it.
Note: Please do not move the object to be tracked quickly, otherwise it will not be tracked correctly
- Find the hex program of this tutorial, right-click the hex program, and upload the hex program of this tutorial to the microbit
- The serial port assistant is set to the interface shown in the figure

- When the K230 camera recognizes the target object, the serial port assistant will print out the information transmitted from the K230 to the micro:bit.
- x: The horizontal coordinate of the top left corner of the recognized box
- y: The vertical coordinate of the top left corner of the recognized box
- w: The width of the recognized box
- h: The height of the recognized box
As shown in the figure below
