www.servomagazine.com/index.php?/magazine/article/march2013_McComb
Discuss this article in the SERVO Magazine forums at http://forum.servomagazine.com

It uses just one of the I/O pins of your robot’s Arduino,
along with a current-limiting resistor and an LED. Code
running in your Arduino is demonstrated in Listing 1.

It merely turns the LED off. Vary the delay value to make
the LED flash on and off at a faster or slower rate. This
sketch is just a variation of the Blink example that comes
with the Arduino software.

Remember that you’re not limited to merely lighting
an LED to show status. You can flash the LED using
different patterns to communicate more variations. Use
Morse Code to relay a variety of conditions or to “speak”
phrases. If you don’t know Morse Code, you can invent
your own system. Table 1 shows just a few ideas. Note
that in each case, there’s an Off pause between the three-flash sequence.

Put the LED where it’s easy to see, and select a
component large and bright enough to make it visible
from across the room — the LED connected to pin 13 on
the Arduino just doesn’t cut it in most instances. I like to
use large 5 mm bright red or yellow LEDs mounted on the
top of the robot that can be seen at any angle.

Use multiple LEDs when you want to quickly convey
operating or sensor status. For example, you might light
an LED each time one of the bump switches or proximity
detectors sense an object. You can then see how the
robot responds to the condition, such as running your
“back up and turn the other way” code. You know there’s
a problem if an LED doesn’t light when it should, or lights
up but the robot doesn’t take the proper action.

When only a small number of LEDs are needed, you
can wire them directly to the I/O pins of your
microcontroller. You simply duplicate the circuit and code
from above, and use a different output pin assignment for
each LED.

If you want to use more than four or five LEDs, then
you probably don’t want to dedicate an I/O pin for each
one. With a simple serial in parallel out (SIPO) shift
register, you can turn three pins into eight.
Refer to Figure 2 for a schematic using a
74595 SIPO integrated circuit. This chip is
widely available and inexpensive at under $1;
you can select any member of the ‘595 family
such as the 74HC595 or 74HCT595 — whatever
is available to you.

Sample program code for the Arduino is
shown in Listing 2. The shift register works by
first setting the latch line to LOW, and keeping
it there for the time being. Then, eight bits of
data is sent bit by bit to the data pin of the