Micro:bit How-to: Make a Treasure Chest with a Burglar Alarm

Description

This micro:bit project combines arts and crafts with coding to make a treasure chest with a burglar alarm. The alarm uses the LED array on the micro:bit as a light sensor. When the lid of the treasure chest is opened, the light on the LEDs triggers the micro:bit to play a sound. The portion of the project that requires coding the micro:bit is easy so it makes a nice beginning coding project.

Programming Language

MakeCode Blocks

Difficulty Level

Beginner

Age Range

9 and up

Materials

Build the Project

The treasure chest has a bottom where the micro:bit is hidden. Here are the steps for building it:

  • Paint and decorate the treasure chest
  • Cut the cardboard to fit the chest opening. Cut a hole big enough to reveal the LED array. Make sure the hole is placed to allow the micro:bit to fit in the box easily.
  • Decorate the cardboard to look like a pile jewels, being careful to not cover the hole for the LED array
  • Attach the micro:bit to the bottom of the insert with some easily removed tape like painter’s tape
  • Turn the battery pack on, place the insert in the box, and close the box

Programming the micro:bit

Develop the problem statement

The problem statement for this project should be something like “make an alarm that goes off if the box is opened”. Here is my problem statement:

Make a siren sound play if the box is opened

This isn’t that complicated. The only thing it specifies is a siren sound.

Write the algorithm

The algorithm needs to get a little more specific about what’s going to cause the alarm to sound and how long it sounds. Here is my version:

  • Check light level
  • If any light is present
    • Play siren sound for 2 or 3 seconds
  • Repeat the above steps forever

Write the pseudocode

Here is my version of the pseudocode:

  • Do Forever
    • Read lightLevel
    • If lightleve > 0
      • Play sound
    • Pause for 3 seconds
  • End Do

Write and test the code

Once you are happy with the pseudocode, go ahead and write the code in MakeCode.

Here is the code I wrote

Academic Connections

Programming Concepts

  • Conditional Logic
  • Sensors

Math

  • Concept 1
  • Concept 2

NGSS Concepts

  • PS4 – Wave properties