My week with Micro:Bit

10 thoughts
last posted Jan. 18, 2016, 11:01 p.m.

8 earlier thoughts

0

Project 5 - Theft Alarm

I started working on this script after I successfully connected Mei-Xiu to a buzzer, but gave up when Mei-Xiu broke. Now I went back to it, the idea is to be able to set an alarm that will go off if the device is moved.

As I now had some crocodile clips I connected the CamJam EduKit buzzer directly to the microbit without the need for a breadboard. I found it easiest to use the pins closer to the Micro:Bit edges, so I connected the longer leg of the buzzer to pin0 (red wire) and the short leg to GND (black wire).

In the script I needed to make sure the device slept briefly before I measured the starting coordinates for the accelerometer when setting the alarm as it is quite hard to keep the device still when clicking a button. After setting the start coordinates, the alarm will be raised if the coordinates change more than a tiny bit. Once the alarm has gone off, it can be turned off by clicking button B (please don't tell that to the thieves).

Here is a video of the alarm in action, shot with some help from the self titled "best hand actor in the world".

Source code can be found here.

1 later thought