About 3 hours
Ages 8+
What Will You Make?
We will create a micro:bit badge which we can wear everywhere, and have fun with the code.
We will continue to create an artificial intelligence model that identifies the voice and controls the LED matrix of our micro:bit.
What Will You Learn?
We will use scratch and techable machine, learning how to program simple programming commands, as well as create a machine learning model to recognize the voice and use this model to interact with our badge.
Code Your micro:bit
Step 1
For programming we are going to use Teachable Machine and Scratch, for communication with micro:bit we go to “https://scratch.mit.edu/microbit” to download its plugin. Follow the instructions for your operating system, we connect our micro:bit to our computer to drag the HEX code we just downloaded into it.
Step 2
Let’s go to scratch 3: https://stretch3.github.io/, we use this version since it has more plugins. We are going to add the “Micro:bit” plugin, the menu to connect our board will appear, we connect our Micro:bit and connect it.
We are also going to add the plugin “TM2Scratch” this will allow us to use our teachable machine model.
Step 3
Now we are going to create our machine learning model we are going to teachable machine: https://teachablemachine.withgoogle.com/train. We select the “audio project” Our workspace is divided into three sections:
Left: are the audio labels.
In the middle: training is done.
Right: where we will test the model and share it.
Step 4
We are going to change “Class 2” to “Make” and we are going to add two new classes, one for the word “off” and another for “i don’t know”, here we will place different words for the model to know more, and can more easily distinguish the words we chose.
Step 5
We go to the “Background Noise” section, click on the microphone and record 20 seconds of background noise. When finished, the “Extract sample” button will appear. Ready we already have 20 samples.
Step 6
Now we will do the “Make” section, click on the microphone and record ourselves for 5 seconds saying the word Make. When finished, we select the word within the audio, we can click on the play button to listen to what we selected and extract the audio sample. We repeat the step until we complete our minimum of 8 samples.
Step 11
Let’s go to the “Events” section and drag the “when pressed (green flag)” block, go to the “TM2Scratch” section, take the “sound classification model URL” block, here we will paste the url. We take the “set confidence threshold 0.5” and change the value from “0.5” to “0.7”. In the menu we go to “micro:bit” and put the “display ” block in the main code block.
Step 12
Go back to “TM2Scratch” and take the “When received sound label (any)” block, then go to the “Control” section and take the “if <> then, else” block and put it after the block above and take another condition and put it inside “yes no”. We go to “TM2Scratch” drag the “sound (any) detected” and put it in the conditions.
Step 14
We go to “micro:bit”, take the “display” block and put it inside the two conditions. In the “make” condition we are going to click on the “()” to put an M and in the “off” condition we clear the screen.
Step 15
Done! Now test your code with the green flag, don’t forget to combine it with your badge.
Resources
Media
What Is Happening Here?
Teachable Machine
We use teachable machine, a Google tool, we manage to create our voice detection machine learning model, including the samples of the words that we want to identify as “make”, “off”, “background noise” and “I don’t know”. Then we join it with Scratch, so that when it identifies each of these it does different actions in our micro:bit.
What Is Next?
Additional Resources
You can experiment with adding more words to customize your badge, or improve your model by adding more samples for better performance.
You can also check out the other projects in the Maker Camp library to create a crochet badge to include your micro:bit.
About MoonMakers
MoonMakers — led by Camila and Diego Luna — are a community of creators passionate about knowledge. A Makerspace, an open space with different digital manufacturing machines. And a YouTube channel where we promote science, technology and the maker movement.
MoonMakers have collaborated with companies such as: Sesame Street, Make Community and in Mexico with Educational Television and Fundación Televisa, creating educational content.
We have given workshops throughout the Mexican Republic with: Talent Land, Secretary of Education in Jalisco, Conacyt, Centro Cultural España.
- Materials/Equipment:
- micro:bit.
- Battery base.
- Batteries.
- micro USB to USB cable