Example Code for micro:bit-Self-service Supermarket Cash Register

Last revision 2026/01/14

This article guides you through creating a self-service supermarket cash register using micro:bit and HuskyLens, detailing hardware setup, software installation, tag recognition, and coding instructions for seamless transactions.

Hardware Preparation

  • HuskyLens: 1
  • micro:bit: 1
  • IO Extender for micro:bit v2.0: 1
  • QR Code tag: 3

Software Preparation

  1. Search https://github.com/DFRobot/pxt-DFRobot_HuskyLens or "HusktLens", then click on the search button, you will see the HuskyLens plugin, and then click to add it.
    search

Wiring Diagram

HuskyLens needs to be connected to the specific interface. The HuskyLens interface uses a 5V voltage supply to ensure stable operation, as shown in the figure:

interface

Other Preparation Work

  1. Dial the function button to the right or left until the words "Tag Recognition" is displayed at the top of the screen.

  2. Press and hold the "function button" to enter the secondary menu parameter settings

  3. Dial the function button until "Learn Multiple" is displayed, then short press the function button, and dial to the right to turn on the "Learn Multiple" switch, that is, progress bar turns blue and the square icon on the progress bar moves to the right. Then short press the function button to confirm this parameter.

    tag  multi-learning

  4. Dial the function button to the left until "Save & Return" shows. And the screen prompts "Do you want to save the parameters?" Select "Yes" in default, now short-press the function button to save the parameters and return automatically.

HuskyLens can only recognize the QR codes as shown in the picture below, and you can choose three of them to label on the products.

QR codes

  1. Tag Detection
    When Huskylens detects the tag, the tag will be automatically selected by the white frame on the screen.
    tag detection

  2. Tag Learning

    After detecting the tag, press the "learning button" to learn the first tag, then release the "learning button" to end the learning, meanwhile, a message "Click again to continue! Click other button to finish" will be displayed. Please short press the "learning button" before the countdown ends if you want to learn other tags. If not, short press the "function button" before the countdown ends, or do not press any button to let the countdown ends.
    tag learning
    The tag ID is consistent with the order of learning tags, that is: ID will be marked as "ID1", "ID2", "ID3" in order, and so on, and different tags correspond to different border tags.

  3. Tag Recognition

When encountering the learned tag, a colored frame with an ID will be automatically displayed on the screen to select the tag, and the size of the frame is same as the size of the QR Code tag.

multi-tag learning

Sample Code

As shown below:

Screenshot3

Program Link:
https://makecode.microbit.org/_CYx3HmKqT2Yw

Result

Press the A button to recognize the product, press the B button to settle the price and display it on the micro:bit LED matrix, for example, press the A button to recognize the QR code on the water cup, and press the B button to settle the price and display it on the micro:bit LED matrix.

Commodity Prices

Name Price
Water cup 20
Flaky pastry 5
Utility knife 15

Was this article helpful?

TOP