Science Oxford Logo

CCC - Treasure Hunt

Resources for the 'Treasure Hunt' Creative Computing Club.

During this workshop, you will program a BBC micro:bit to detect other micro:bits and show you how close or far away you are from it.

This page recaps what we discussed as a group.


Creating your first program

Click here for the starter program containing the functions you will need later in the workshop. Click Edit Code to open your own version of the program!

MakeCode editor window

Drag and drop code blocks (click into the Basic menu), to recreate this code:

on start, display string

You will see it running on the emulator on the left of your screen.


Follow the instructions to pair your micro:bit, then click Download to send your code to your physical micro:bit.


Communicating with your treasure

Step 1: make sure your micro:bit only listens for one of the treasure boxes

Step 2: listen out for string (text) messages

Step 3: do some background maths to work out the signal strength

Step 4: prepare a bar graph

Step 5: plot a graph of the signal strength


Your final code should look like this:

code as described above, with three events showing: function check-signal; on start; on radio received receivedString

Test our your code - does the graph change as you get nearer to the treasure boxes?

Try to find our own treasure box - when you think you have found it, check the micro:bit inside and make sure that it shows the number of your computer.

photograph of treasure box with a micro:bit inside

Do you want to know what message the micro:bit is sending to you?

Add a couple more blocks of code:

After sending the new code to your micro:bit, click Show data Device under the Emulator.

code as described above, with three events showing: function check-signal; on start; on radio received receivedString

What now?

You can choose what to do next. You could...

Work on only one thing at once - having two micro:bits can get confusing!