micro:bit — Wireless Social Distancing

Workshop Resources

What is a micro:bit?

What is a micro:bit? A micro:bit is a programmable mini computer! It can be coded from any web browser in various languages like javaScript, Python, Scratch, and Blocks. For our session today, we will be using MakeCode Blocks. Your micro:bit has the following physical features: 25 individually-programmable LEDs 2 programmable buttons Physical connection pins Motion sensors (accelerometer and compass) Wireless communication via bluetooth radio USB interface If you want to learn more about each individual component and all the features that come with your micro:bit, you can click here. »

Broadcasting a Signal

Turning On the Radio Today we’ll be using the Bluetooth radio on your micro:bit to figure out how far away you are from other micro:bits. The first thing we need to do is turn on the radio and tune it to a channel. Click on the section that says Radio. It’s the pink section which is fifth from the top. Choose “radio set group 1” and drag it into the blue “on start” block in the workspace. »

Receiving a Message

Now that we’re sending messages and listening for them, we need to use that information to find out how close together or far apart our micro:bits are. To do that, we need to know how strong the signal we’re receiving is. Go back into the Radio section and this time drag the “on radio received (receivedNumber)” block and drag it to an empty spot on your workspace. It should not be inside of any other block. »

Interpreting Signal Strength

Now that our micro:bit knows how strong the signal it got is, we need to use that to figure out how close we are. Click on the Logic section and grab the “if true then / else” block. Drag that inside the radio received block, just under where we set the strength variable. Go back into the Logic section and drag the 0 = 0 comparison on top of the true on the “if true then” line. »

Lighting it up

We have all our logic written, but no way to tell if we’re more than 6 feet apart. Now we’ll add some lights so we can actually see when we’re far enough apart. Click the Basic section at the top and drag a “show icon” block into the if part of our logic block. Click on the icon to see a list of other icons and choose the sad, frowning face. »

Downloading the code and trying it out

Downloading the code and trying it out Now that our code has been written, it’s time to try it all out. First, we have to pair the micro:bit with a computer. Find your USB cable and connect the smaller side to the silver USB port on the top of your micro:bit. Connect the other, larger end to a USB port on your computer. On the MakeCode workspace, click the ellipsis (…) next to the Download button to make a small menu pop up. »