Microbit Escape Room Puzzle - Magnetic Alarms

In this project, you and a partner will create an alarm that will go off when a magnet is moved away from the microbit. In many escape rooms, magnetic sensors are used to detect if certain objects are placed in the correct position. To make our program easier to troubleshoot, we will have our microbit make a noise when a magnet is moved close to it.

Author: Taylor Plantt
Grade Level: 6-8
Materials: Micro:bit, Magnets, headphones, alligator clips

OVERVIEW

Activity Overview:

In this project, you and a partner will create an alarm that will go off when a magnet is moved away from the microbit. In many escape rooms, magnetic sensors are used to detect if certain objects are placed in the correct position. To make our program easier to troubleshoot, we will have our microbit make a noise when a magnet is moved close to it.

Meta description

  • Subject Area: Computer Science
  • Grade Level : 6-8
  • Computer Science Domains:
    • Algorithms and Programming
  • Computer Science Principles:
    • Collaborating Around Computing, Creating Computational Artifacts, Testing and Refining Computational Artifacts
  • Materials:
    • Micro:bit, Magnets, headphones, alligator clips
  • Considerations:
    • This lesson assumes that students already have a little bit of familiarity with the makecode microbit website as well as the microbit itself. This lesson is also designed to be discovery based and encourages students to look at the documentation of code blocks to learn how to use them.

Lesson Plan

Overview

In this project, you and a partner will create an alarm that will go off when a magnet is moved away from the microbit. In many escape rooms, magnetic sensors are used to detect if certain objects are placed in the correct position. To make our program easier to troubleshoot, we will have our microbit make a noise when a magnet is moved close to it.

ASSESSMENT PRE/POST-TEST

What is the function of a “forever” code block? What code/block can be used to have your program do one action if something is true, or another action if it is false? How does a “show string” block work? How does a “ring tone” block work? What does the “magnetic force” code block do?

OBJECTIVES

Correctly use a forever loop to keep parts of their code running continuously Use an If/else statement to have their program behave differently under different conditions Use various coding blocks and logic states to have their microbit react to a magnetic field.

CATCH/HOOK

Demonstrate a working microbit magnetic alarm that starts to play a noise when a magnet is moved far enough away from it. Ask students what they think is happening physically and what is happening in the code.

ACTIVITY INSTRUCTIONS

Use makecode.microbit.org to create a magnetic alarm - that is to have your microbit play a noise when a magnet is moved away from it.

BEFORE YOU BEGIN CODING: FInd the following blocks of code, right click on them, and select the “help” option. Then read the documentation for that block so that you understand how it works! You will have to search through the block options on the left side of the screen to find each of these. “Forever” block “If…else” block “Show string” block “Ringtone (hz)” block “Magnetic force” block

Your program should do the following: Display the magnetic force number on the screen when the microbit is measuring a magnetic field strength less than 400. Play some sort of noise when the microbit measures a magnetic field strength of more than 400.

Now that you have read about all the blocks you need, it is time to start coding and testing!

Supplements

Any items in this section are the property & under the license of their respective owners.

REVIEW

Have random pairs of students demonstrate their magnetic alarm and briefly explain their code.

STANDARDS

TypeListing
CS DomainsAlgorithms and Programming
CS PrinciplesCollaborating Around Computing, Creating Computational Artifacts, Testing and Refining Computational Artifacts
Other Content Standards