Radio Approval

by 8060160 in Circuits > Software

168 Views, 0 Favorites, 0 Comments

Radio Approval

bbc_microbit_board_hardware.jpg

This Microbit Instructable shows how the Microbit technology can make a hold of the radio feature in order to communicate with other Microbits on the same signal. It shows the potential of what the software can handle. This tutorial was designed to help those who are struggling with understanding how to get these Microbits to be able to communicate with each other as this could potentially open up many doors in the future once you understand the fundamentals of what is being done here.

Photo via: https://opensource.com/article/19/8/getting-started-bbc-microbit

Supplies

This task only works in the physical as if you attempt to recreate it using the online simulators the code will not work as it is supposed to.

You will need:

3 Microbits (Labeled)

A makecode account

Confidence

Step 0.5 Planning

2021-11-07 17_44_26-Attendance - Google Sheets — Mozilla Firefox.png

Failing to plan is planning to fail so make sure to first set aside some time before diving deep into creating this task. This is a basic plan that I made before creating this very instructable you see before your eyes. I recommend you make a similar one before attempting this tutorial.

Step 1.) Starting the Setup to the First Microbit

2021-11-07 14_43_04-Microsoft MakeCode for micro_bit — Mozilla Firefox.png
2021-11-07 15_47_22-Microsoft MakeCode for micro_bit — Mozilla Firefox.png

Now that we're ready let's start!

Click new project and give it a title. I would highly recommend titling it after whatever you have labelled your first Microbit firstly so you can immediately tell your code files and micro bits apart from each other but also so you can easily link the right code files to your Microbit.

In My case, I had labelled my Microbits by colour so I named this first project Blue

Step 2.) the Code for the First Microbit (part 1)

2021-11-07 14_46_01-Microsoft MakeCode for micro_bit — Mozilla Firefox.png

Now that you've started a new project it's time to get coding!

First, go to the radio button to the side and drag across the "Set radio group" block. Pick any number from 1 to 255 and write it in the bubble. Make sure to remember which number you pick however because you'll need later.


Next, add the on shake block that can be found in the Input section. Drag across radio send number from the radio section. Make the send number "1". Drag across the blocks show number, pause (ms) x2, clear screen x2, and show icon all of which can be found in the basic section. Set show number to 1, pause (ms) to 500 ms and the Icon to a cross.

This will let us know whether the message has gone through to the other radio's as the cross will change to a tick when it's done once the final product has finished.

Step 3.) Microbit 2

2021-11-07 14_43_04-Microsoft MakeCode for micro_bit — Mozilla Firefox.png
2021-11-07 14_42_39-Microsoft MakeCode for micro_bit — Mozilla Firefox.png
2021-11-07 14_50_57-Microsoft MakeCode for micro_bit — Mozilla Firefox.png

Exit out of the first project and start a second one. In my project, I called this "Yellow" but once again you can call it whatever is the most helpful to you.

Drag over the block "radio set group" from the radio bar and add it to the "on start" block. Make sure to set the radio group number to the same number on the previous project (look back and check if you've forgot it)

Next drag over "on radio received receivednumber" from radio. Add the following blocks to it. Show number, pause (ms) and clear screen all from the basic section. Also, add radio set number from the radio section. Make sure the blocks are in the order shown in the picture. Set show number to 2, send number to 2 and pause to 500 ms.

Congratulations were all done with Microbit 2's code!

Step 4.) Microbit 3

2021-11-07 14_42_52-Microsoft MakeCode for micro_bit — Mozilla Firefox.png
2021-11-07 14_51_18-Microsoft MakeCode for micro_bit — Mozilla Firefox.png

First, do the same as before and start a new project. For reference mines called "pink".

Next, drag over the blocks "Radio set group" and "Radio set string" from the radio section. Also make sure to drag over the blocks "show icon", "Pause (ms)" and "clear screen". arrange them all in the order shown in the picture and make sure to put them all in the "on start" block.

Set radio group to the same number as the other two projects then set "show icon" to a tick. This will mean the third microbit will display a tick when the radio signal is given to it. Set the "radio send string" to whatever you want as it doesn't really matter but in this example ill set it as "approve" for ease of understanding. Lastly, make sure to set pause (ms) to 500 ms.

Step 5.) Return to Microbit 1

2021-11-07 14_42_17-Microsoft MakeCode for micro_bit — Mozilla Firefox.png
2021-11-07 15_49_03-Microsoft MakeCode for micro_bit — Mozilla Firefox.png
2021-11-07 17_15_39-Microsoft MakeCode for micro_bit — Mozilla Firefox.png

Now return back to the main makecode menu and open back up your first project. This is for the final touches of your code.

Drag over the block "on radio received recievedstring" from the radio section. Drag over show icon, pause (ms) and clear screen. set the show icon to a tick. This means that the first Microbit will change from a cross to a tick when all three of the radios are in communication with each other. Next, go to the music section and drag over the "play melody at tempo" block. you can set it to whatever sound you like but I have mine set to 120 BPM with a pattern of the middle lowest followed by the middle highest. This means that when the Microbit is working it will play a friendly, comforting jingle to let you know everything is working as it should.

Lastly we let the Microbit pause for a few seconds before it then clears itself in order to make a full reset for the next attempt.

Step 6.) Download Your Code and Upload It to Your Microbit

2021-11-07 17_18_00-.png

The last major step is to download your code and move it to your Microbit.

In order to do this click the large purple button at the bottom of your project screen that says download. Once this has been completed simply drag this file to your Microbit that's plugged into your computer. It's just like moving a file from the downloads to a USB stick.

Step 7.) Enjoy

Congratulations legend on managing to successfully get 3 microbits to communicate with each other purely with the power of microbit radio. You can use this technology in the future to go wherever your mind takes you. The future is now in your hands in your creativity is the only true limit of where you can go with these newfound skills.

The video attached is an early demo of what the final product should look like when it's complete. The numbers light upon each one when their talking and the third Microbit changes to a heart when it receives the message. This is followed by the first Microbit changing to a heart when the message changes back to a heart.

Make sure to celebrate this achievement of learning some new skills in coding. You deserve it!

Step 4.) Sources

This code was heavily inspired by MartineLassen's Instructable titled "Radio Signals on Micro:bit". It can be found here:

https://www.instructables.com/Radio-Signals-on-Microbit/

Also, partial credit of this task goes to my Network and security class teacher Gwilym Lucas for helping me fix some of the bugs in my code.