you’re using such a receiver, you don’t have to deal with all the complicated
transmission details. You can focus on reading and interpreting the incoming
signals.
The image that follows shows how to connect a TSOP38238 receiver to an
Arduino. It’s cheap, it’s easy to use, and it works at a frequency of 38 kHz,
so it detects signals from a broad range of devices. Connect its ground con-
nector to one of the Arduino’s GND pins, the power supply to the Arduino’s
5V pin, and the signal pin to digital pin 11.
You might be tempted to write a sketch that reads and outputs all incoming
data on pin 11, and I won’t stop you. Call
digitalRead
in the
loop
method and
output the results to the serial port. Point your TV set’s remote to the receiver
and see what happens.
You’ll probably have a hard time understanding the data you see. The problem
is that decoding the incoming data isn’t easy. Even if the receiver has already
processed the data, it still has to be transformed and interpreted according
to some complicated rules. Also, Arduino’s
digitalRead
method is too slow to
deal with all types of incoming signals. You have to directly access the micro-
controller to get the best results.
Fortunately, we don’t have to do this ourselves, because the IRremote library
2
hides the nasty details. It supports the most popular infrared protocols, and
it can both receive and send data.
After you’ve downloaded and extracted the zip file,
3
rename the resulting
directory to
IRremote
. Copy the directory
IRremote
to either
~/Docu-
ments/Arduino/libraries
(on a Mac) or
My Documents\Arduino\libraries
(on a Windows box).
Then restart your IDE.
2.
https://github.com/shirriff/Arduino-IRremote
3.
https://github.com/shirriff/Arduino-IRremote/archive/master.zip
Chapter 12. Creating Your Own Universal Remote Control • 204
report erratum • discuss
www.it-ebooks.info