AI with ZOOM:BIT: Tag Recognition

AI with ZOOM:BIT: Tag Recognition

In this project, ZOOM:BIT will be moving along a track. To make smart decisions about its movement, it will use Huskylens to identify special tags placed along the way.


Video Tutorial



How Does This Project Work?


We'll train ZOOM:BIT to recognize 3 different tags. Each tag will instruct ZOOM:BIT to perform specific action.



If it sees the first Tag assigned to ID 1, ZOOM:BIT will make a U-turn.


If it sees the second Tag assigned to ID 2, ZOOM:BIT will make a left turn at the next junction.


If it sees the third Tag assigned to ID 3, ZOOM:BIT will come to a complete stop.



Project Requirements


In this project, we'll be using special markers called April Tags. These are like little black and white squares with unique patterns that Huskylens can easily recognize. By teaching Huskylens which code belongs to each tag, ZOOM:BIT will be able to understand what to do when it sees them on the track.



You can download and print these tags from the link below. This design contains four different tags. For this project, we'll only need three of them, leaving the fourth as a spare for you to use as you like.

Download link:



Once you have the tags printed, follow this guide to prepare them for the project.



1. Cut along the dashed lines.


2. Fold each piece at the dotted lines.


3. Glue the base of the paper and stick the other end to it.


Before we proceed to build the code, we need to tilt down the Huskylens a bit so it can see the tags placed on the track.



Building the Code


Firstly, we'll need to add ZOOM:BIT and Huskylens extensions in MakeCode Editor. Once they are ready, we can jump into building the code.

You can view and download the complete code from here.



What the Code Does?


The code starts by setting up Huskylens for tag recognition. The servo motor's position is set to 90 degrees. Then, we create two variables, 'position' and 'start,' and set them to 0. The 'position' variable helps ZOOM:BIT better track the line's position, and the 'start' variable is used to initiate movement.



After the initial setup, ZOOM:BIT enters a standby mode, waiting for a trigger. In our case, the trigger will be a loud sound. Once the trigger is detected, it exits the while loop, displays a square icon and then enters the Forever loop.



Pressing Button A teaches ZOOM:BIT to recognize the tag it sees as ID 1.

Pressing Button B teaches ZOOM:BIT to recognize the presented tag as ID 2.


Pressing both Button A and Button B together teaches ZOOM:BIT to recognize the presented tag as ID 3.


Pressing the logo clears all learning data from Huskylens.



With the help of Maker Line Sensor, 'followLine' function allows ZOOM:BIT to follow the track by adjusting its speed and direction based on the detected position of the line. When the line is detected off-center, ZOOM:BIT adjusts its motor speeds to recenter itself on the track. The 'position' variable helps ZOOM:BIT remember which way to turn when it goes off the line, so it can get back on track when it sees the line again. You can check out ZOOM:BIT's resource hub for more information about the line following function.



When uTurn function is called, ZOOM:BIT brakes and then turns right. It continues to turn right as long as line is not detected on center. It stops turning when it is back on track [i.e. when line is detected on center].



Inside the turnLeftAtJunction function, ZOOM:BIT continues to follow the line until it reaches the junction. Then it stops and moves forward to position itself correctly before turning left. After that, it continues to turn and only stops when it is back on track.



Inside Forever Loop, ZOOM:BIT continuously requests data from Huskylens and checks for tags. If ID 1 is Detected: ZOOM:BIT plays a simple tone and calls the 'uTurn' function.


If ID 2 is Detected: ZOOM:BIT plays another tone, and calls the 'turnLeftAtJunction' function.


If ID 3 Detected: ZOOM:BIT stops and blinks the headlights.


If no Tags are detected, ZOOM:BIT calls the 'followLine' function to keep moving forward along the track.



Please keep in mind that for all these functions, you will need to fine-tune the speed and delay settings. Note that motor performance, battery level, and surface conditions can affect the actual outcomes, so adjustments may be necessary to achieve optimal performance.


Project Complete

Congratulations on completing the final project of the ZOOM:BIT & Huskylens series! You've learned how to use ZOOM:BIT and Huskylens together to create amazing AI projects. We hope you enjoyed this series and feel inspired to keep exploring the world of robotics and coding. Thanks for joining us on this journey.

Hardware Components

ZOOM:BIT Robot Car Kit for micro:bit

$37.25++ $47.50++ $37.25

x 1 unit(s)