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.
Now, let’s create the AI that will send the signal.
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:
Bluetooth
category in your menu.Show Connection Status:
Bluetooth
drawer, drag out an on bluetooth connected
block.Basic
drawer, place a show icon
block inside it and choose an icon that means “connected,” like a diamond.on bluetooth disconnected
block, but choose an icon that means “disconnected,” like a small square.Start the Right Bluetooth Service:
on start
block to an empty part of your workspace.Bluetooth
drawer, find the bluetooth uart service
block and drag it into the on start
block. This special service allows the Micro:bit to send and receive text strings over Bluetooth.Create a Variable to Store the Signal:
Variables
drawer, click “Make a Variable…”.receivedString
and click OK.Build the Main Command Listener:
Bluetooth
drawer, 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.”Variables
and drag in the set receivedString to
block.Bluetooth
drawer, find the bluetooth uart read until new line ()
block and snap it into the set
block. Your code now reads the incoming text and saves it to the receivedString
variable.Program the Actions:
Logic
drawer, drag two separate if...then
blocks and place them one under the other inside the on bluetooth data received
block.if
, go to Logic
and drag a 0 = 0
comparison block into the condition slot. Change it to look like this: receivedString = "Yes"
. (You’ll find the receivedString
block in Variables
).if
block, place a show icon
block and choose a “check mark” or “happy face” icon.if
, build the condition receivedString = "No"
.if
block, place a show icon
and choose an “X” or “sad face” icon.if
, build the condition receivedString = "Nothing"
.if
block, place a show icon
and choose an “Umbrella” or “sad face” icon.Your final code should look identical to the one in the image below!
6. Download the Code:
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
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:
Load Your AI Model:
Connect Your Micro:bit:
Test Your Creation!
You have successfully created a wireless, AI-powered switch for your assistive technology prototy