CS170: Programming for the World Around Us - Hide and Seek with the micro:bit

Activity Goals

The goals of this activity are:
  1. To use the radio interface of the micro:bit
  2. To design a workflow and algorithm to play Hide and Seek with two micro:bit devices
  3. To implement an algorithm using the micro:bit block language
  4. To create button events using the micro:bit
  5. To use if statements to make decisions in a program

The Activity


Consider the activity models and answer the questions provided. First reflect on these questions on your own briefly, before discussing and comparing your thoughts with your group. Appoint one member of your group to discuss your findings with the class, and the rest of the group should help that member prepare their response. Answer each question individually from the activity, and compare with your group to prepare for our whole-class discussion. After class, think about the questions in the reflective prompt and respond to those individually in your notebook. Report out on areas of disagreement or items for which you and your group identified alternative approaches. Write down and report out questions you encountered along the way for group discussion.

Model 1: Hide and Seek using the micro:bit

But I still haven't found what I'm looking for.


  1. How do you think Tiles or Apple AirTag devices might work?
  2. What equipment do you think these devices require?
  3. What features of the micro:bit might help us locate our item? As a hint, think of the game Marco Polo.
  4. Develop a flowchart for the Marco Polo or Hide-and-Seek game (who says what, and who does what). For this flowchart, let's decide if we're getting "warmer" or "colder" at each step.

Model 2: Designing an Algorithm with a Flowchart and Implementing the Algorithm

An algorithm flowchart for the Hide-and-Seek game


  1. What is unique about the diamond shapes on this flowchart?
  2. Using MakeCode, represent the strength of the radio signal as a variable.
  3. Each time you receive a radio message, copy the current signal strength to a new variable that represents the previous signal strength, so that we can compare the two to see if the current one is stronger (larger) or weaker (smaller). We’ll do this every time we receive a radio message (“on radio received”)
  4. When should you update the “previous signal strength” variable, and to what should we set it?
  5. What should we do if the signal is stronger or weaker?

Model 3: Enhancing the Program

Apple AirTag


  1. When should we send a radio signal (i.e., "Marco!")
  2. Should we do this over and over again, or pause in between? Why or why not?
  3. Which two devices are playing the Hide-and-Seek game here? How can we modify the program to allow each pair to communicate with one another without interfering with the others?
  4. Modify the program to set radioNumber to radioNumber + 1 mod 30 and display the radioNumber variable value each time the B button is pressed.
  5. Why was it important to check if receivedNumber = radioNumber when a message was received? Why was it helpful to send the radioNumber as the message?
  6. Why did we initially set the RSSI variables to -100 on start? What would happen if we set these variables to 0 instead, or to something else?
  7. Modify the program to display the current signal strength value when the A+B buttons are pressed together (at the same time).
  8. How might you display the hot-and-cold result as a numeric value in feet or meters, rather than a generic "warmer" or "colder"? How might we figure out the best way to convert the RSSI signal value to a distance?


I encourage you to submit your answers to the questions (and ask your own questions!) using the Class Activity Questions discussion board. You may also respond to questions or comments made by others, or ask follow-up questions there. Answer any reflective prompt questions in the Reflective Journal section of your OneNote Classroom personal section. You can find the link to the class notebook on the syllabus.

Teacher Highlights

  • Teachers can set up a MakeCode Classroom environment by activating this template.