Infrared remote control receiver.
Contents |
Bill of materials:
Manufacturers design their receivers using different pinouts:
Printable version: Single, Double
The pin of the microcontroller where CMIR-RC is connected to has to be configured as a digital input.
When you press a button on your remote control, it will send a stream of bits encoded as a sine wave of infrared light at a given frequency. This means your remote control will generate a series of zeroes and ones (digital bits). Those bits will have a lenght depending on the protocol used by that remote control. A lack of infrared light would mean a zero is being transmitted. Digital ones are sent as a sine wave at a specified frequency. The infrared receiver has an internal demodulator which will detect those sine waves and output a continuous signal, so at the receiver's output you'll get a square wave easy to process by the microcontroller.
A more detailed explanation about how infrared remote controls work can be found here.
Also, note that its output is inverted, so digital ones sent by the remote control will be received as a zero, and zeroes sent will be received as ones.
Depending on the modulated frequency your remote control is using, you'll have to use a different TSOP17xx model:
The most common ones are 36 and 38kHz. If you are not sure which one you should buy, you might be interested in TSOP1736. If you remote control happens to work a different frequency you'll still be able to receive the signal, but at closer distances.
All the information about each infrared receiver can be found in their datasheets: TSOP17xx, SFH5110.
The resistor is optional, but it's a good idea to include it because in case you set the microcontroller's pin as digital output both components will become a short-circuit.
The following code can be compiled using SDCC.
/*================================================================== * Sample program for CMIR-RC and LTIND-A using an MBP18 * * Plug CMIR-RC to RB3 (pin 9) and LTIND-A to RB4 (pin 10). * The LED will flick while you are pressing a button on your * remote control * * http://curuxa.org *=================================================================*/ #include <MBP18.h> ConfigBits1(_CP_OFF & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO); #define IrReceiver RB3 #define LED RB4 #define LedON 1 #define LedOFF 0 void main(){ //set RB3 as a digital input and RB4 as a digital output TRISB3=DigitalInput; TRISB4=DigitalOutput; while(1){ if(IrReceiver==0) LED=LedON; else LED=LedOFF; } }