Joseph, aged 15, won the Mothers and Carers Challenge with a set of Python Utilities for the micro:bit: an alarm; compass; egg timer; key finder; teeth brushing timer and burglar alarm. Joseph presents his utilities.
Hex and Python files (if file does not automatically download Save link for Mac, Save target for PC):
main.hex and main.py
key_finder.hex and key_finder.py
burglar_alarm.hex and burglar_alarm.py
The alarm, compass, egg timer, key finder and teeth brushing alarm are all on a single hex file which needs to be downloaded and flashed onto your micro:bit. The key finder and burglar alarm need separate hex files. In all the utilities, button A is for minor actions, for example toggling through a menu or sleeping the alarm. The B button is for major actions such as selecting a utility/option from a menu or exiting a utility. Most utilities require sound; for this a speaker needs to be connected between pin zero and ground.
The alarm utility helps wake you up. It has a choice of sounds, times and has a sleep mode. In order to access it, use the A button to toggle to the image of a bell (fig. 1) and then press the B button to select the alarm utility. You will be presented with a menu that allows you to select which alarm sound you want (fig. 2); the options are:
·‘D’ - The opening to Beethoven’s 5th Symphony in C minor.
·‘N’ - The Nyan Cat theme.
·‘F’ - A funky bass line for secret agents and criminal masterminds.
·‘P’ - The theme of Monty Python’s Flying Circus.
Toggle through with the A button and select using the B button. You will next be presented with the time select menu (fig. 3), it is possible to select a time between one and nine hours, toggle through the menu with the A button and select a time using the B button. The alarm is now set (fig. 4), if you want to end it you can press B. When it comes to an end your chosen sound will play and a fireworks animation (fig. 5) will be played. You can sleep the alarm for five minutes by pressing the A button (fig. 6) or exit the utility by pressing B.
The compass utility helps you determine which direction is north as well as bearings. In order to access this utility toggle through the initial menu with A until you find the image of a compass (fig.1) and press B to select it. You will be presented with a tool to help calibrate the compass (fig. 2), rotate the micro:bit in every direction in order to calibrate. Now the compass is calibrated, the compass needle (fig. 3) will be displayed pointing in the direction of north. You can find the bearing (fig. 4) by pressing A and exit the utility with B.
The egg timer utility helps you boil the perfect egg, you can select whether you want them hard or soft and their progress is shown with the hand of a clock. In order to access the egg timer, toggle through the menu with the A button and locate the image of an egg (fig. 1); press B to select it. Now you will have the choice of whether you want your egg hard or soft (fig. 2); the options are:
·‘H’ - Hard - 8 minute timer.
·‘S’ - Soft - 4 minute timer.
Toggle through the menu with B and select your choice. The progress hand (fig. 3) will now be displayed, once it has made its way around the alarm will sound and a firework animation (fig. 4) will play. In order to exit to the menu press B.
The key finder utility solves that age old problem of lost keys. You will need two micro:bits. First download the key_finder.hex
file and flash it onto the second micro:bit and connect it to a battery pack, speaker and your keys. On your micro:bit navigate to the key image (fig. 1) using A in order to use the key finder. Press the B button and the second micro:bit should receive a signal and start playing music. If this is successful a tick (fig. 2) will be displayed on your micro:bit. Locate the keys using the music and press B on your micro:bit to stop it. If the signal is unsuccessful a cross (fig. 3) will be displayed.
This utility helps time the optimum teeth cleaning duration. Toggle using A to the image of a tooth (fig. 1) and press B. This will start the two minute tooth timer, progress is shown with the hand of a clock (fig. 2), it can be stopped early by pressing B. When the time is up an alarm will be played and a firework animation (fig. 3) will be displayed. You can exit the utility with B.
This is an additional utility that requires the burglar_alarm.hex
file to be downloaded and flashed onto your micro:bit. Connect a speaker between pin zero and ground and a wire between pins one and two. When this wire is broken, the alarm will be triggered.
Joseph created a video to show off his utilities:
(This article is reproduced with the tutorial
from micro:bit website. Thanks!)