remote, it will send the same code over and over again as long as you press
the key. An Apple remote will send the key’s command code only once, and
after that it sends the code 0xffffffff as long as you press the key.
Figure 30—Capture the IR codes of a Samsung remote
After you’ve grabbed a remote’s control codes, you can use them to build your
own remote. You’ll learn how to do that in the next section.
Cloning a Remote
As soon as you know the protocol and the
command codes a remote uses, you can
clone it. You need only an infrared LED
that doesn’t differ much from the LEDs
we’ve used before. The only difference is
that it emits “invisible” light. The figure
shows how to connect it to pin 3 of an
Arduino. (The library we’re using in this
section expects the infrared LED to be
connected to pin 3.) Note that you can’t
use an LED without a resistor. (See Cur-
rent, Voltage, and Resistance, on page 239,
to learn more about it.)
We could try to generate the infrared sig-
nals ourselves, but that’d be tedious and
error-prone. It’s better to use the existing
implementation in the IRremote library.
We’ll use it to create our own
TvRemote
class that encapsulates all of the gory protocol details. Here’s the class:
report erratum • discuss
Cloning a Remote • 207
www.it-ebooks.info