Example Code for Arduino-IR Receiving
For the ir receiving feature, we recommend to use [Arduino IRRemote library](https://github.com/shirriff/Arduino-IRremote) created by Ken Shirriff. This library is quite easy to use and directly support decoding several different IR protocol.
Software Preparation
Other Preparation Work
Please download the arduino library and install it before compiling the sample code
Sample Code
//Please download the arduino library and install it before compiling the sample code
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
int RECV_PIN = 4; //IR Receiving pin on the driver shield
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
Was this article helpful?
