Example Code for micro:bit-Face Recognition(Mind+)

Last revision 2026/01/20

This article details the process of connecting HuskyLens to micro:bit for face recognition using Mind+, covering hardware setup, software preparation, and coding to display results on the micro:bit's dot-matrix screen.

This chapter demonstrates how to connect HuskyLens to the micro: bit board, then the micro: bit board reads the face recognition results from HuskyLens. If HuskyLens recognizes you (the learned face), the dot-matrix screen of the micro: bit displays a smiling face, otherwise it displays a crying face.

The communication protocol between HuskyLens and micro: bit is I2C.

Mind+ Introduction

Mind+ is a Scratch 3.0-based programming tool, which allows you to build a program by dragging and snapping coding blocks. With tons of tutorials, sample projects and a large community, it is one of the best tools for you to learn programing from absolutely zero!

Mind+ supports a wide range of hardware including Arduino, micro:bit or even a series of ESP32-based educational microcontrollers.

Please view Mind+ official site to download the latest Mind+.

Hardware Preparation

Wiring Diagram

The following picture is only for reference when wiring. The R and T pins of HuskyLens (their functions are SCL and SDA here) are connected to the SCL (P19) and SDA (P20) pins of the micro: bit respectively. The communication protocol between HuskyLens and micro: bit is I2C.

A micro: bit expansion board is recommended for simplify wiring.

Huskylens_Wiring_Diagarm_Microbit

HuskyLens consumes heavy current, up to 3.3V 320mA or more. The mciro: bit board is not enough to supply power. Therefore, external power supply is required. You can connect the external power supply to the external power connector of the micro: bit expansion board or the USB connector of HuskyLens.*

Software Preparation

Load HuskyLens Extension

  1. In the upper right corner of the Mind+ window, dial the switch to the offline mode.

    MindplusOfflineMode

  2. Click the Extensions button in the lower left corner to view the extensions window.

  3. Select a board. Here we select the micro:bit.

    MindplusSelectBoard

  4. After selecting the board, the corresponding extension labels become selectable. Then click Sensor label, find HuskyLens. Click it to load.

    You can enter the sensor's name in the search bar in upper right corner when there are many sensors listed in the menu.

    MindplusSelectSensor

  5. After selecting the board and extensions, click Back button in the upper left corner to return to the programming window.

    MindplusLoadExtensions

HuskyLens Protocol Setting

You need to set the protocol type of HuskyLens. The protocol should be I2C. Of course, your can adopt the auto detect protocol, which is easy-to-use and convenient.

HuskyLens_Protocol_Setting_I2C

Sample Code

Drag and snap the coding blocks to program, and make a simple face recognition projects. The sample code is shown below.

Mindplus_Face_Recognition_Sample_Code

Results

  1. Click the Connect Device button, then select the COM port corresponding to the microbit.

    If no COM port is found or you use mcirobit for the first time, please click the Install Serialport Driverbutton to install the driver with one click.

    Mindplus_Select_COM

  2. Click the Upload button to upload the sample code to your micro:bit board.

    Mindplus_Upload

  3. Let your HuskyLens learn your face first.

  4. When HuskyLens recognizes your face, the dot-matrix screen on the micro: bit board will show a smiling face. If it were not your face, or no face appeared, it would display a crying face.

Was this article helpful?

TOP