The GPS module I’m using is an older
module from Parallax. The ground and power
pins are connected to ground and 5 VDC,
respectively. The serial I/O pin was connected to
pin 4 on the Arduino.
Since this module is a “smart” GPS, it’s
expecting a serial conversation with us asking
for specific parameters like latitude and
longitude. Since the TinyGPS++ module will be
parsing the raw NMEA data strings, we need to
tie the /RAW pin low.
The gripper servo needs 5 VDC, ground,
and signal from pin 9 on the Arduino. If you
connect the Arduino’s ground to your quad’s
ground, you could power the servo from your
BEC on the quad.
In this case, I’ve simply powered it off the
Arduino as my battery can handle the drain; we
won’t be putting an incredible demand on the
servo. I just used some male/male jumpers
directly into the servo’s connector with some
electrical tape, but an extension cable could also be used.
Finally, I used a small tactile button for the gripper
toggle. I connected one terminal to ground, and the other
to pin 5 of the Arduino. We would normally add a pull-up
resistor here (say, 10K) to 5 VDC on the pin side of the
switch, but later we’ll see how to use the Arduino’s internal
pull-up resistors. You can see the final setup in Figure 3.
I highly advise testing the circuit on a walk around the
neighborhood before mounting it onto your quad. Once
everything is working properly, then mount it to your
airframe. It could be as simple as zip ties or Velcro® straps
for our initial tests.
In writing the firmware for this, I elected to not bother
with a full-fledged state machine. This is just too simple of
an application. If we were adding a lot of additional
functionality or sharing the processor with other
equipment, it would be a different story. In this case, we
have a dedicated Uno.
As always, start your design on paper (or digital paper
if you desire) with a set of requirements. For our
application, I came up with the following list:
• Be able to change the state of the gripper (open or
closed) with a button at any time to allow loading.
• When within the error bounds of the target, toggle the
state of the gripper (to open or closed, whichever it is not).
• Be able to specify open/closed positions easily in the
firmware for different grippers.
• Immediately after the toggle of gripper state at the
target, shut down; accepting no further button or GPS
• Indicate the gripper state with an LED for
• Have a debug serial output showing the distance to the
• Start up with the gripper in the open position.
Looking at the requirements, I see a setup state, the
main loop, a function to toggle the gripper state, and a
shutdown state that effectively stops all action. Let’s quickly
go through how we’ll do each of these.
The Multi-Rotor Hobbyist
SERVO 01.2018 13
Figure 4: Library includes, object creation, and constants.
Figure 3: The circuit is simple, consisting of a GPS module, pushbutton, and
servo. For a more permanent installation, a proto shield could be used.