Overview
This library unit will let you easily read and decode the infrared signals from a Sony compatible television remote control. In particular, the remote control transmits a pulse modulated signal, the sensor detects this, and the procedure in this unit decodes the signal, returning two numbers: one representing the device (television, VCR, DVD, tuner, etc.), while the the other returns the key which has been depressed (VOL+, MUTE, channel numbers 0 through 9, etc.).
This has been tested and confirmed with a fixed remote control purchased surplus for $2.00 from All Electronics, an universal remote control set to Sony mode, as well as a keychain remote.
Moreover it has also been tested with a Panasonic IR sensor and a Vishay sensor, each purchased surplus for about fifty cents.
Every combination performed well, and it is probably the case that most any garden variety 38 kHz IR sensor will work. The only tricky bit is making sure you get the pinout for your sensor correct; search out the datasheet for whichever device you use. There are only three pins:
- Ground
- Vcc
- Data
The Data pin requires a 4.7k pullup resistor. This is an original library unit, but includes some parameter passing improvements suggested by Philippe Paternotte.
Compilation Constants
There are two compilation constants required of the calling program. Together, these indicate which port line the IR sensor is connected to. For example,
{$DEFINE IR_PORT, 'PortA'}
{$DEFINE IR_PIN, 0}
The data direction port is taken care of automatically, but be sure you have turned off the analog connections, if any.
Command
There is only command. Its format is:
procedure readIR(var dev, cmd : byte);
It returns the device number and the command code of the pressed button.
A bit of explanation for the device number is needed. Many remote controls (especially so-called "universal" remotes) can accommodate televisions, VCRs, DVDs, stereos, etc. So, the value returned here will tell you which device the received command code was intended for.
Add It to Your Library Collection
And here's the new library unit, "SonyRemote.pas" for you to download:
Be sure to read over the source code for additional details on how to use it.
Try It Out
If you'd like to see it in operation, then head over to the exercises to find the IR remote control project. Click here to go to it.
No comments:
Post a Comment