The latest version of the BBC micro:bit is now powerful enough to run machine leaning. This project builds a system running on the micro:bit which can identify TikTok dance routines using the onboard accelerometer.
Throughout the project you will learn how to collect training data, build a neural network classifier and deploy it on the micro:bit using Edge Impulse We used it to build a micro:bit that can identify when someone is dancing the “Floss” TikTok.
At the time of publication, (16/11/20) this project requires the Beta version of MakeCode https://makecode.microbit.org/beta This should change to the standard version https://makecode.microbit.org in the future, please see https://microbit.org/beta-testing
The dance move transmitter is battery operated and held by the dancer. It uses the accelerometer to sense the dance moves. Each reading consists of an x-axis, y-axis and z-axis comma-separated string (x,y,z). The data samples are sent over radio to another micro:bit which acts as the dance move receiver.
The top left LED on the display should blink showing that data is being transmitted
This micro:bit acts as the receiver for the accelerometer data and streams it to the PC. Attach it with the micro USB cable to your PC.
When the dance move transmitter is sending accelerometer readings, the top left LED on the display will blink to show that data is being received.
The machine learning capability is provided by Edge Impulse. This is a browser-based studio for developing machine learning models. It is also used to produce C/C++ libraries of your trained model that can run standalone on the micro:bit.
$ npm install -g edge-impulse-cli
Before dance data can be collected the micro:bit dance move receiver needs to connect to Edge Impulse.
Further details of using Edge Impulse Data Forwarder are here.
It’s now time to start collecting dance move samples for model training. Two types of samples need collecting; random dance moves and “Floss” TikTok moves. This will allow you to build a machine learning model that can distinguish between the two classes of data.
Once enough training data has been collected the machine learning pipeline can be configured.
Now just click through the following buttons to set up the model features.
Once the features have been generated, you should see in the Feature Explorer a nice separation of the two different data classes – indicating that a good machine learning model can be created. The “random dance” samples are in yellow and “floss” samples nicely separated in blue below:
This step builds a machine learning model representing the collected data set.
Once the training process has finished you can review the accuracy of the model.
Now the model can be tested to see if it can identify the TikTok dance movements.
The model should be able to detect your dance now.
This step generates the C/C++ libraries that will be used to build the standalone model that runs on the micro:bit.
This will generate a compressed .zip file which should be saved to your PC.
This step integrates your specific machine learning model with the dance move project code and builds the firmware for the micro:bit.
$ git clone https://github.com/LetsOKdo/dance-activated-microbit.git
$ python build.py
This is the final step where you can test that everything is working.
A single LED should be ON in the centre of the display to indicate the ML model is running.
Now try your TikTok floss dance moves – the display will show a smiley as soon as it recognises the dance!
Machine Learning is an important technological development that is now within reach of the micro:bit with its latest revision. Edge Impulse is a powerful environment that simplifies many of the complexities of building Machine Learning models and makes it easy to deploy them on the micro:bit to do interesting things.
Further information about building Machine Learning models with Edge Impulse can be found in this video tutorial and on their website.
Hopefully following this project will have given you a good insight into Machine Learning and demonstrated its amazing capability on the micro:bit, in a fun way, so you can go and build your own.
You can find more information and resources for your micro:bit here: https://microbit.org/
Please select an option to see content specific to your location and shop online.