Your robotic problems solved here.
To post comments on this article and find any associated files and/or
downloads, go to www.servomagazine.com/index.php/magazine/issue/2017/09.
photocells. They are not RoHS compliant, so they
may be gone in 5-10 years. For the time being,
however, they’re plentiful and cheaper than dirt (I
live in Los Angeles).
You can pay 95 cents each at Adafruit, and see
their tutorial at https://learn.adafruit.com/
photocells. On eBay, pay just 99 cents for 30
photocells and free shipping at
www.ebay.com/itm/172568435252! At that price
— RoHS or not — every project we build should
Whoever comes up with a great use for LOTS of
these can make a fortune in the short term. Here’s
my big idea: PIR motion sensors are great for
detecting that someone’s there — especially at night.
Unfortunately, they don’t give us any directional
information; just that someone is in their field of
view (180 degrees?). I need to know where the intruder is
For daylight applications, I humbly suggest the eight-photocell sensor shown in Figure 3. Photocells and ADCs
(analog-to-digital converters) to monitor them are cheap
and plentiful. Isolate the photocells in light-tight baffles
looking in different directions so that you know where the
light changed. Target that zone and launch your attack!
I’ll build this defense system sooner or later, so stay
tuned. Now, let’s get to some reader questions:
Q. I’ve been working with my new Arduino Uno and have mastered flashing LEDs and dimming them with PWM (pulse width modulation). I’m ready to
move on. I’ve tried hooking up motors in place of the LEDs,
but I can’t get them to turn at all. I was hoping to control
their speed with PWM. Isn’t that what it’s for?
A. Congratulations and condolences! I’m happy to hear that you’re a successful “coder” now. It’s very rewarding and liberating to learn how to program.
LEDs are a great starting point for controlling output pins
and learning PWM. However, motors are a different and
potentially dangerous animal where microcontrollers are
Connecting a motor directly to your Arduino may kill
your pins; hopefully you didn’t. When Billy Joel crooned,
“From the HIGH to the LOW, to the end of the show, for
the rest of their lives,” and Styx chanted “nothing ever goes
as planned,” they were talking about the intricacies of
An Arduino Uno is one of the “strongest” controllers
around; it uses an AVR chip. Any single pin is rated for up
to 40 mA maximum before it risks burning up. In
comparison, one Propeller pin delivers 30 mA max; BASIC
Stamps and PICs are 20-25 mA max; and Raspberry Pis are
16 mA max. It’s not good practice to try to draw that max
current — especially not for long or for multiple pins, which
can cause many other problems.
LEDs draw small currents — usually 10-20 mA max —
which are within the limits of these chips. In most cases, an
LED is used with a series resistor to limit the current to safe
levels. Hooking up an LED to a micro without a resistor will
draw excessive current. The LED will be nice and bright until
it or the micro’s output pin burns up. It’s no biggie to toss a
bad LED, but a damaged micro pin is forever. It’s almost like
a blown fuse on that pin.
If you’re lucky, only that one micro output pin gets
damaged. If you’re REALLY lucky, it might still work as an
input even if the output channel is damaged.
DC motors have only a few ohms of resistance and are
practically a short circuit at startup; see https://www.
Even small DC motors draw hundreds of milliamps. No
micro pin can deliver that much current directly, so you
need a buffer circuit in between. Let’s look at a few
Relays are electromechanical solenoid-controlled
switches which can provide complete isolation (no common
connections) between a delicate controller circuit and a
high power DC motor circuit. Relays are used for switching
on/off only — not for speed control. One relay is generally
used for on-off in one direction. Two or more relays can be
used for on/off and forward/reverse control.
Relay contacts come in several different configurations
(Figure 4). Reed relays (Figure 4B) are for low power
applications. Most have single pole/single throw (SPST)
contacts rated for ~500-1,000 mA. Some have coils which
SERVO 09.2017 9