Facial Recognition and Assistive Technology
You’ve explored what assistive technology is. Now, let’s give your Micro:bit a “brain.” You will teach a computer to recognize your unique actions—like a smile, a head nod, or a specific sound—and use that to send a wireless signal to your Micro:bit, turning it into a truly smart device.
Today’s Goals
- Program your Micro:bit in MakeCode to react to a wireless signal.
- Train a custom AI model to recognize your unique gesture, expression, or sound.
- Connect your AI model to your Micro:bit, making your action trigger the device from across the room!
- Brainstorm how this AI-powered “switch” can be used in your own assistive technology prototype.
Materials You’ll Need
- A computer with a webcam and microphone 💻
- Your Micro:bit with battery pack and USB cable
- Prototyping materials (cardboard, foil, tape, etc.)
Part 1: Train Your AI “Switch”
Now, let’s create the AI that will send the signal.
- Open Teachable Machine: Go to Teachable Machine and start a new Image Project (for gestures/expressions) or Audio Project (for sounds).
- Create Two Classes:
- Class 1: Your “ON” Switch. Name this after your chosen action (e.g., “Smile,” “Head Tilt Left,” or “Ahh Sound”). Record at least 100 examples.
- Class 2: Your “OFF” Switch. Name this “Neutral.” Record yourself looking straight ahead or just record the quiet background of the room.
- Train and Export: Click “Train Model.” When it’s finished, click “Export Model” and then “Upload my model.” Keep the sharable link that it generates open in a new tab. You will need it in the next st
First, let’s program your Micro:bit to listen for specific commands using Bluetooth. This will allow your computer to send signals directly to your device as if they were connected by an invisible wire.
Open MakeCode & Add Bluetooth Extension:
- Go to the Microsoft MakeCode for Micro:bit website and start a new project.
- Click on “Extensions” at the bottom of the block menu.
- Select the “Bluetooth” extension. You will see a warning that Radio blocks will be removed. Click “Add extension” to continue. You will now have a blue
Bluetoothcategory in your menu.
Show Connection Status:
- From the
Bluetoothdrawer, drag out anon bluetooth connectedblock. - From the
Basicdrawer, place ashow iconblock inside it and choose an icon that means “connected,” like a diamond. - Do the same for the
on bluetooth disconnectedblock, but choose an icon that means “disconnected,” like a small square.
- From the
Start the Right Bluetooth Service:
- Drag the
on startblock to an empty part of your workspace. - From the
Bluetoothdrawer, find thebluetooth uart serviceblock and drag it into theon startblock. This special service allows the Micro:bit to send and receive text strings over Bluetooth.
- Drag the
Create a Variable to Store the Signal:
- From the
Variablesdrawer, click “Make a Variable…”. - Name the new variable
receivedStringand click OK.
- From the
Build the Main Command Listener:
- From the
Bluetoothdrawer, drag out the main event block:on bluetooth data received new line (). This block will run whenever the Micro:bit receives a text command that ends with a “new line.” - Inside this block, go to
Variablesand drag in theset receivedString toblock. - From the
Bluetoothdrawer, find thebluetooth uart read until new line ()block and snap it into thesetblock. Your code now reads the incoming text and saves it to thereceivedStringvariable.
- From the
Program the Actions:
- From the
Logicdrawer, drag two separateif...thenblocks and place them one under the other inside theon bluetooth data receivedblock. - First Condition: For the first
if, go toLogicand drag a0 = 0comparison block into the condition slot. Change it to look like this:receivedString = "Yes". (You’ll find thereceivedStringblock inVariables). - Inside this
ifblock, place ashow iconblock and choose a “check mark” or “happy face” icon. - Second Condition: For the second
if, build the conditionreceivedString = "No". - Inside this
ifblock, place ashow iconand choose an “X” or “sad face” icon. - Third Condition: For the second
if, build the conditionreceivedString = "Nothing". - Inside this
ifblock, place ashow iconand choose an “Umbrella” or “sad face” icon.
Your final code should look identical to the one in the image below!
- From the
6. Download the Code:
- Click the “Download” button. MakeCode will ask you to pair with your Micro:bit.
- Connect your Micro:bit to the computer with your USB cable and follow the on-screen instructions to pair it.
- Once paired, click Download again to transfer the program to your Micro:bit.
Your Micro:bit is now a smart device, ready and waiting for the “Yes” or “No” or “Nothing” commands from the AI you’ll build in the next activity.
Trouble with your code? Try mine! https://makecode.microbit.org/S97652-06532-55963-10690
Part 3: Connect AI to Your Micro:bit
This is the bridge between your AI model in the cloud and the physical Micro:bit in your hand. We will use your webcam that send the correct commands to your device over Bluetooth using the cardboard.lofirobot website.
Go to the cardboard.lofirobot Website:
- Open this specific page in Google Chrome: https://cardboard.lofirobot.com/teachable-microbit/
Load Your AI Model:
- Find the shareable link you got from Teachable Machine in Part 1 (see image below for link).
- Paste this link into the text box labeled “Teachable Machine URL”. Your class names (e.g., “Smile,” “Neutral”) will appear below.
Connect Your Micro:bit:
- Make sure your Micro:bit is plugged in and showing the “CheckerBoard” icon from the code you downloaded.
- On the website, click the blue “Connect Micro:bit” button.
- A Chrome pop-up window will appear and start scanning. Select your Micro:bit from the list and click “Pair”. If successful, the button on the website will turn green and say “Micro:bit Connected.”
Test Your Creation!
You have successfully created a wireless, AI-powered switch for your assistive technology prototy
