This is our first hardware project - an alarm. It's (very) inspired by Tech Will Save Us' Micro Guardian. The project is pretty simple, but it's a fun one to make. We set up the micro:bit with a connection between pins 0 and 3v using crocodile clips attached to two strips of copper tape. The copper tape goes across the seal of a jar, making a connection when it's closed and breaking it when it's open. We detect this in the code and, when the connection is broken, we output a pulse to pin 1 which has a buzzer connected to it (the other connection of the buzzer goes to GND). We also used some of MicroPython's built-in images to show the micro:bit asleep face when the connection is closed, and alternating between angry face and sword (Son was insistent that the micro:bit show you that it is both angry and ready to fight you) when open.
We followed the first Tech Will Save Us' first step ('The Jar') to set up our jar - coincidentally we had exactly the same jar. We found their instructions and pictures a little bit unclear, so we'll mention that we bend the copper tape back on itself to make a loop to clip the crocodile clips onto:
We also went for different wiring. Our wiring diagram looks like this:
And that looks like this when we wired it up for real on the micro:bit:
Here's our complete code:
Python and hex files as per usual: