Micro:Bit Mood Communicator

by Lukaiii in Circuits > Microcontrollers

292 Views, 1 Favorites, 0 Comments

Micro:Bit Mood Communicator

Untitled drawing.jpg

this instructable was created as my first Micro:bit project for a school assignment. It is a simple radio network that broadcasts to any Micro:bits' on the same radio group of 1 that displays the mood you are currently feeling using the buttons implemented on the Micro:bit

Supplies

RE25mkU.png
RE2MOYU.png
  • Windows / Mac or Linux based computer that has access to the internet (used for coding Micro:bit)
  • Micro:bit (Optional, an online simulator such as Microsoft's 'MakeCode' can be used)

Adding in the Radio Extension

Screen Shot 2021-11-05 at 12.22.12 am.png

From the side menu click into the 'Advanced' drop down menu and than the 'Extensions' Menu, from there install the extension named 'radio-broadcast' and return back to the workspace.

Setting the Radio Group (on Start)

Screen Shot 2021-11-04 at 11.34.34 am.png
Screen Shot 2021-11-04 at 11.55.16 am.png
Screenshot 2021-11-04 173900.png

Clicking into the 'Radio' section on the left, look for the 'Radio Set Group' and drag this block into the workspace and set it to any Radio group, the example here has set it to '1'

Optionally you can add a greeting message to the user which has been done in the second example this can be done by going to the 'Basics' section on the left and dragging in the block 'Show string'. From there you can add any greeting by typing into the text box.

The Second example also adds a start-up tune (again optional). This is done by going to the 'Music' section on the left and dragging in the block 'Play Melody' into the start-up chain, from there you can edit what melody it plays with the editor shown in the third image.

Adding in the 'Happy' Functionality (Button A)

Screen Shot 2021-11-04 at 9.42.00 pm.png
Screen Shot 2021-11-04 at 9.41.48 pm.png

Clicking into the 'Input' section on the left, drag out 'On button Pressed' on to the workplace and change the value to 'A'. Afterwards, looking in the 'Radio' Section drag out 'Radio Send' block into the workplace setting the value to anything (in the example it has been set to 'SpencerHappy') and place into the 'On button Pressed' block.

Adding in receiving end of the code revolves going into the 'Radio' section and dragging 'On Message received block' into the workplace setting its value to the same as the value set in 'Radio Send' block. from there you can add any message using blocks of code from the 'Basic' section as shown by the second image

Additionally the example has used music from the 'Music' section to add onto the function. this was done by dragging the 'Play sound' Block into the workplace and selecting which sound to play, the example has used 'Twinkle'

From here you duplicate the steps above to make other commands from buttons 'B' and 'A+B' there are provided examples of this in steps 4 and 5 although alternative messages can be made with the use of different coding

Here is what this function should look like,

Adding in the 'Sad' Functunality (Button B)

Screen Shot 2021-11-05 at 12.27.14 am.png
Screen Shot 2021-11-05 at 12.27.37 am.png

Look for the 'On Button Pressed' under the the 'Input' Section and drag it out to the workplace and from the drop down menu change the value to 'B', and than looking in the 'Radio' section select the 'Radio send' block and and drag it into the 'On button pressed' setting the value to anything (the example has set it to 'YABAI' shown in the image)

Dragging in the block 'On Radio Recieved' from the 'Radio' section and from the drop down menu select the same value as the one as the 'Radio Send' block (in this example it is set as 'YABAI' which is shown in the second image) after setting this up, use the 'Basic' section to set up the message that you would like displayed after sending the function, this can be shown set up in picture two.

Here is what the finished function code should look like,

Setting Up the 'Fine' Functionality (button A+B)

Screen Shot 2021-11-05 at 11.38.36 am.png
Screen Shot 2021-11-05 at 11.39.04 am.png

Again, we look for the 'On Button Pressed' block under the 'Radio' Section and drag it into the workspace, we navigate once again to the 'Radio' section and drag out another 'Radio Send' block setting the value to anything (the example has had it set to 'ok') and attaching in to the 'On Button Pressed' Block.

Looking into the 'Radio' section again drag out the 'On Radio Received' block and using its drop down menu set it to the same value as set in the 'Radio Send' block (in the example it has been set to 'ok'), by doing this when the 'A+B' button is pressed the other Micro:bits on the same radio frequency will receive the radio signal. Using blocks from 'Basic' allows you to set up any message to be displayed when this signal is received an example can be shown in the second picture.

The following video shows how the function should look like after completing,

Adding in a Loudness Funcutionality

Screen Shot 2021-11-05 at 5.12.32 pm.png
Screen Shot 2021-11-05 at 5.12.46 pm.png

From the 'Input' Section drag out a 'On Sound' block into the workplace and using the drop down menu select the value 'loud', and from the 'Radio' Section drag out a 'Radio send' block setting the value to anything (the example has set it to 'LOUD') this block is than place inside the 'On Sound' block, this is shown in the first image.

going to the 'Radio' section on the left drag out a 'On Radio Received' block and using the drop down menu select the same value that the 'Radio Send' block has been set to (the example has been set to 'LOUD'), from the 'Basics' selection menu on the left drag in blocks to crate the message that you want shown (the example has used a 'Show icon' block to make a cross be displayed), this is shown in the second picture

The following video shows how this function looks,

Complete Snapshot + File Download

Screen Shot 2021-11-05 at 11.54.44 am.png

This is the finished code that powers the project.

Although being completely functional there are many other improvements that could be made to make the project better such as

  • Message sending Animations
  • Other ways to implement different ways to create and send messages
  • Creating better messages to send off with Micro:bits

Attached below is the a downloadable .hex file for the project that can be imported into a MakeCode account, this can allow you to look at the code and make changes.