I funded the
MakeTronix Alarm on IndieGoGo because it contains many of the
components I usd with Raspberry Pi at CoderDojo, but in one compact
package. Don't get me wrong, I'm all in favour of having learners
build the circuit using a breadboard, but sometimes there just isn't
the time to do that and code it.
The board arrived
very quickly and it is a nice, neat package. I was pleased that they
kept the board to 26 pins as this will enable it to work with my
trusty set of original mode Bs.
The online
documentation is easy to find but I have to say I found it a little
disappointing. It seems weird to not show a picture of the board
mounted on a Pi in the “connecting the board” section. The
written description is entirely accurate but a simple diagram would
be much better, especially for younger users. I was also surprised
to find that the code examples downloaded from the MakeTronix github
don't use gpiozero. There's nothing wrong with using the Rpi.GPIO
library – it works perfectly – but I believe gpiozero is much better for
those who are new to Python and this board is being marketed as a
“fantastic educational circuit board for learning programming”.
They've tried to abstract out the key functions into a library file
that the other examples import, but this feels a bit unwieldy, again
especially for novice Pythonistas.
I also couldn't get
the full alarm code to work. It turned out this was nothing to do
with the code: the PIR that shipped with my kit didn't work correctly
and would not trigger on motion at any sensitivity. Luckily I have
plenty of these PIRs and substituting in a replacement got
everything working.
Nevertheless I
decided to write a gpiozero version. It uses a couple of lambda
functions which you might argue are too opaque for beginners (and I'd probably agree) but
they do remove the need to give each button its own when_pressed
function individually.
Here's why I love
gpiozero – all sorts of hardware control is possible with simple,
easy to understand syntax. My MTAlarm code does the following:
1. Activates the PIR
and waits for motion to be detected. The LED glows/pulses to indicate
that the alarm is active.
2. When motion is
detected, the LED starts flashing.
3. If within 10 seconds the correct code
is entered (each key beeps when pressed and DEL acts as backspace) the
alarm is disabled.
If not, the buzzer starts to beeeeeep constantly.
If not, the buzzer starts to beeeeeep constantly.