32 SERVO 11.2017
follow the build of the
final version of the
system in the November
2016 issue of SERVO.
The Bean is
equipped with a
Bluetooth module, RGB
prototyping area, and
coin cell power. Perfect!
feature of the Bean is
that it’s programmed
over Bluetooth via the
regular Arduino IDE
environment) or the
Bean Loader iOS/Android
I recently acquired a
12. 9” iPad Pro and
wondered if I could take
a simple project from
start to finish with only
the iPad (including
writing this article).
The only things the
Bean didn’t have
onboard were the buzzer and the arming mechanism. I
again found a surplus piezo buzzer in my junk bin and
soldered it onto the prototyping area. I connected the
positive terminal of the buzzer to pin 3 of the Bean.
Any pulse-width modulation (PWM) capable pin will
work (Figure 4). I then connected the negative terminal to
ground through a 1K resistor (Figure 5).
The arming mechanism is just going to be a high/low
state detection on a pin. I soldered a wire to pin 4 of the
Bean and the other to ground. For testing, I just left them
as flying wires since the mounting problem hadn’t been
thought about yet (Figure
6). In terms of actual
hardware assembly, that’s it!
I like that there are only a
few connections to make as
they would be the first
things to go during a hard
The firmware is written
in C++ like any other
Arduino project, but we
have some additional
functionality through the
Bean library. You can learn
about these through the
reference on Punch
Through’s website or by
exploring the macros menu
in the apps. Being able to
insert the correct call from a
menu makes development
run very fast with fewer fat-finger typos.
Like any microcontroller project, we should start out by
designing a state machine diagram. In this case, things are
We have an initialization, check for free fall, and alarm
state. We could add a wait state in there if we wanted, but
this program is simple enough we won’t follow a strict
design pattern like we have in the past.
We will handle all the initialization tasks in the setup
function as it only runs when the microcontroller powers
up. In this state, we set the range of the accelerometer (to
± 4g in this case); enable the low g motion event (more on
that later); make sure the RGB LED is off (0, 0, 0); set the
buzzer pin to be an output; and set the arming pin to be
an input with the internal pull-up resistor enabled (Figure 7).
In the main loop that runs over and over again, the first
thing we need to do is check if the system is armed.
Figure 5: I added the piezo buzzer
to the prototyping area and tucked
the resistor to ground away under
the PCB. This Bean has been used
in a lot of temporary/
demonstration projects and the
PCB has seen a few better days.
Figure 6: Arming wires are
attached to ground and pin 4.
Figure 7: This setup function runs when the unit is powered up,
and takes care of housekeeping like configuring the
accelerometer and GPIOs.
Figure 8: The main loop handles any state transitions,
as well as determining if the system is armed or
To post comments on this article and find any associated files
and/or downloads, go to www.servomagazine.com/index.php/magazine/issue/2017/11.