Create a Real-Life Sorting Hat from Harry Potter with the Power of HUSKYLENS

0 85597 Medium

Welcome to Hogwarts, young wizard! Step right up and discover which of the four legendary houses you belong to with our magical Sorting Hat - brought to life using HUSKYLENS and micro:bit technology. As showcased at BETT 2023 London, this project has been a huge hit with our young audience.



The project relies on HUSKYLENS' face recognition algorithm, which can detect and identify faces. To create the Sorting Hat, we trained HUSKYLENS to recognize four famous characters from the world of Harry Potter. Once a face is recognized, the micro:bit is programmed to illuminate the light ring with a color that corresponds to the character's Hogwarts house. However, if an unfamiliar face is detected, the Sorting Hat will randomly assign it to one of the four houses - making every sorting experience unique and exciting!

1 micro:bit
1 micro:bit IO Expansion Board
1 RGB LED Ring
Choose Function

To switch to face recognition mode, simply use the function button and turn the dial left or right.


Learn Object

Learn the faces of these four characters in sequence.

1. Detect Face: 

Point the HUSKYLENS at the object until the object is selected by a white frame. 


2. Learn Face:

Press the "learning button" to learn the object and the frame changes its color. 


3. Continue Learning:

If you want to continue learning another object, press the "learning button" before the countdown ends.  


4. Forget Learned Faces: 

Point at one learned object, press the "learning button" and press again.  


Connect Hardware

1. Connect the HUSKYLENS to the I2C port.

2. Connect the LED Ring to P8 on the expansion board.

3. Power the expansion board using the power plug.

4. Connect the micro:bit to your computer to start programming. Once the program is uploaded to the micro:bit, you can unplug it from the computer.

Start Programming

The sample code is written in Mind+, which you can download for free at mindplus.cc.

icon HUSKYLENS Sorting Hat.zip 173KB Download(2)
Detect Object

Point the image of the character or your face at the HUSKYLENS camera. When HUSKYLENS detects a learned face, the tiny LED next to the camera flashes green. And when the face is unknown, the LED flashes blue. Then, wait for the LED ring to indicate which house you belong to!

All Rights