Skip main navigation

Challenge 4: Coding the radio

Watch as Lorraine Underwood codes two micro:bits to send radio messages
20.1
Another feature of the micro:bit is that it can send radio
22.6
messages to other micro:bit that are within range. Let’s try that out.
27.4
If you want to send messages to another micro:bit, you have to be in the same group. Let’s have a look at the Radio menu, and we have radio set group one.
36.2
So when I start up my micro:bit, I’m going to set myself to group one.
40.5
That means I can send messages to other micro:bit who are also in group one, and I can receive messages from them. So let’s try this out.
52.9
So I’m going to send the number 11 to anybody who is in group one.
60.4
So let’s go back to the micro:bit homepage– MakeCode homepage– and create a new project.
72.4
For my second micro:bit, let’s join group one like before. But this time, we’re going to– when we receive numbers– remember, the first Microbit sent number 11 to us. We’re basically going to show that number.
96.1
So we’re going to say: here’s the number that has been sent to me.
105.6
It’s more difficult to do this in the simulator, but there is a way round. Let me show you a web page that you need to go to. We need to go to this new web address here, and that will give us two screens where we can code
117.9
multiple micro:bits at the same time. So I’m going to open up my two pieces of code that I’ve just created.
127.3
So once they’ve loaded, we can see the simulators down here in the bottom.
130.9
So when on this micro:bit on the right, when I press A,
136.1
it’s going to send a number to this micro:bit here on the left.
140.2
When this micro:bit receives the number, it’s just going to show it. So let’s try it out.
147.9
Let’s bring them up full screen. So when I press A, there we go– number 11.
157.4
OK, let’s try and make that a bit more obvious that something’s happening there. So I’m just going to create a variable. This is like our step program. And I’m going to change steps by 1 every time I press A. And then, I’m going to send the variable steps to the other
177.8
micro:bit. The step is going to start off at zero, and every time I press A, it’s going to increase. So let’s see– 1, 2, 3. So you can see that’s like the antenna, and it’s flashing every time it sends a signal.
196.6
So this micro:bit the code is not on here. All it’s doing is receiving, showing the information that
201.6
it’s receiving from this micro:bit.
204.2
So that’s one way we can use two micro:bits without actually having any hardware, just using the simulator.

The radio on the micro:bit is one of its most useful functions. Let’s learn how to use it.

This article is from the free online

Build a Physical Computing Prototype

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education