Here's a library that allows the Arduino to receive IR codes from a universal remote:
http://wikiputer.org/arduino/NECIRrcv.zip
The library implements the NEC IR protocol, so set up the universal remote for any NEC device (TV, DVD, VCR, ...) and the 32-bit codes should be received.
The example sketch provided just prints out IR codes as they're received, so it's good to run that sketch to see what codes the remote is sending, so they can later be used to trigger specific actions:
// look for IR codes and print them as they are received
#include <NECIRrcv.h>
#define IRPIN 4 // pin that IR detector is connected to
NECIRrcv ir(IRPIN) ;
void setup()
{
Serial.begin(9600) ;
Serial.println("NEC IR code reception") ;
ir.begin() ;
}
void loop()
{
unsigned long ircode ;
while (ir.available()) {
ircode = ir.read() ;
Serial.print("got code: 0x") ;
Serial.println(ircode,HEX) ;
}
}
The library is implemented to be similar to the Serial library functions 'begin,' 'available,' 'flush' and 'read.' Each IR code is 32-bits long (fits in an 'unsigned long' data type) and there's a buffer that can hold up to 8 codes before overflowing.
Timer 2 is used by the library.
Hardware required in addition to the Arduino is a universal remote control (any cheap one will do) and an IR detector (I used Vishay TSOP1138, $4 from http://www.rentron.com/remote_control/PNA4602M.htm#1138). The recommended circuit for the TSOP1138 includes a 4.7 uF cap and a 100-ohm resistor (see: http://www.rentron.com/Files/TSOP11xx.pdf. Pin 3 of the detector (active low) is directly connected to an Arduino input pin.
For example, I set up a $6 GE universal remote to one of its NEC TV modes and get this output from the example sketch after pressing the numbers 0-9 on the remote:
NEC IR code reception
got code: 0xB24DE718
got code: 0xB946E718
got code: 0xB54AE718
got code: 0xB748E718
got code: 0xB847E718
got code: 0xB44BE718
got code: 0xB649E718
got code: 0xB04FE718
got code: 0xB34CE718
got code: 0xB14EE718
Joe