■ FIGURE 2. Zoomed in view of
burst at eight milliseconds. Burst is
comprised of 28 flashes of infrared
light at 56 kHz. Each flash is about
nine microseconds long.
the receiver separate out IR code
information from background light.
IR Code Sources
A universal remote control contains an abundance of
IR code data. These are available for about $9 at
department and electronic appliance stores. Look for a
remote that stores many codes with a manual code search
to scroll one-by-one through the codes. This functionality
allows for easy code capture. For example, more than 200
codes are easily captured from a GE 24991 three-Device
The circuit used to capture IR codes centers on an IR
receiver module such as RadioShack part number 276-
640. The circuit is shown in Figure 3 and it uses an
Arduino Duemilanove to collect and send the codes to
the PC. The IR receiver in this example was taken from a
broken DVD player.
Figure 4 is the schematic for the circuit. It works by
holding pin 2 high until an IR signal is detected, then pin 2
goes low. The receiver outputs a constant signal when it
detects the modulated carrier signal. Or put another way,
the signal will appear like Figure 1 with the rapid flashes
shown in Figure 2 removed. This is an efficient way to
capture data because each flash is not signaled which
greatly reduces the amount of data to manage.
A concern with this method is that the IR receiver
module is designed to capture a given modulation
frequency. For example, 38 kHz in the case of the
RadioShack module. Signals at very different frequencies
may not be reliably detected. A validation check showed
good results with a signal at 55 kHz, so the large majority
of codes will be captured effectively with this method.
The Arduino program for capturing codes named
“Code_Collector” is short and is provided in the
downloads section for this article. It utilizes interrupts to
scan for signal changes from the receiver module, records
the time in microseconds, then stores the data in an array.
When the code is collected, the program automatically
calculates burst durations and outputs the data as an
Arduino statement. This makes for easy copy and paste of
the data into the program that transmits the codes. Here’s
a short example output:
PROGMEM prog_uint16_t code13 =
This statement will store the code in Arduino Flash
memory. As an example of how to decipher the code, this
one is code 13 and has 19 elements. The modulation
frequency is 38 kHz. There are 17 pulse durations ( 19
elements minus 1 element that holds the frequency, and
minus 1 element that holds the number of pulses). The
first pulse is always an “on” pulse and, in this case, it is
1.14 ms long (114/100). There is then an off pulse of 1.15
ms, on for 3. 41 ms, and so on. The pulse durations are
multiplied by 100 to avoid the need for decimals.
■ FIGURE 3. Circuit to capture IR codes
using an IR receiver module.
■ FIGURE 4.
Schematic for IR
receiver. It works by
holding pin 2 high
until an IR signal is
detected; then pin 2
February 2011 31