Code your Micro:bit to Send a Message Using Bluetooth

Use the 'radio' function to send and receive messages using the Bluetooth antenna.

Step 1

The micro:bit has a built-in Bluetooth Low Energy antenna. This allows the micro:bit to send and receive messages over a wireless Bluetooth connection.

To send and receive messages, use blocks from the Radio palette.

Create this code to display a square on the screen when the micro:bit is first turned on.

Step 2

Create this code to tell the micro:bit to send a message. This will use the Bluetooth radio to broadcast the number 5. Use any number.

When you send a message using this block, it sends it out to everyone – not just one specific micro:bit. This is called broadcasting. Just like a radio broadcast, any device that is listening (if they are 'tuned in') will be able to receive the message if they are close enough.

Step 3

Use this code to tell the micro:bit to do something if it receives a message on its radio.

When the micro:bit receives a message it shows a happy face and then waits for one second, before changing back to the square.

Download this code onto two micro:bits and test it out.