Microbit
Intermediate
60 mins
Teacher/Student led
230 points
What you need:
Chromebook/Laptop/PC
Microbit

Microbit Radio Messages

Discover the world of radio communication with Microbits. Learn how to create a new project, set a radio group, and send and receive different types of messages including string, number, and name-value messages. Explore the possibilities of radio blocks and test your code on two Microbits.
Learning Goals Learning Outcomes Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Introduction

    Microbits have a radio transceiver built into them. A transceiver is an electronic device which is a combination of a radio transmitter and a receiver, hence the name. It can both send and receive radio waves using an antenna, for communication purposes.

    For this project you will need 2 Microbits so you can send and receive messages.


    2 - Create a new project

    Go to the https://makecode.microbit.org website and create a new project.

    3 - Choose a radio group

    The first thing we need to do is set the radio group that our Micorbits will be broadcasting on. A radio group is the channel that the Microbit both sends it's messages and listens for other messages. A Microbit can only send or receive in one group at a time.

    A Microbit that is on radio group 2 will not be able to receive a message from another Microbit that is on radio group 3. However if they are both on radio group 3 then then we can communicate with each other.

    Add the following code to set the radio group to 1.

    radio.setGroup(1)

    4 - Send a message

    We can send different types of messages, we can send:

    1. A string (text) message.
    2. A number message.
    3. A name and value message.

    Let's start off my sending a string message. Add the following code to send the message "Hello" when you press the A button.

    input.onButtonPressed(Button.A, function () {
        radio.sendString("Hello")
    })

    5 - Receive the message

    We are going to be putting the same code on both the Microbits so we will also add the code to receive the string message and then display it.

    Add the following code.

    radio.onReceivedString(function (receivedString) {
        basic.showString(receivedString)
    })

    Run your code in the simulator and you will notice that a second Microbit appears in the simulator.

    Download your code onto both of your Microbits and test that it works by pressing the A button on either of them. When you do the other Microbit should show the message.

    Note that you will need to power both of your Microbits.


    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of DigitalSkills.org. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more