Delete comment from: Ken Shirriff's blog
Awesome library!
I used a new apple remote with the library and was able to find when a button was pressed. I thought it might be cool to control some kind of robot with this!
Here is the 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
int RECV_PIN = 2;
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);
irrecv.resume(); // Receive the next value
}
if (results.value == 4001586391) { //change the number here if your remote isn't working to the number that show up in the serial moniter if you tap the button.
Serial.println("up"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011254963) {
Serial.println("up fast");
}
if (results.value == 2836161645) {
Serial.println("down"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011246771) {
Serial.println("down fast");
}
if (results.value == 2323227209) {
Serial.println("right"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 222827497) {
Serial.println("left"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011271347) {
Serial.println("left fast");
}
if (results.value == 2011259059) {
Serial.println("right fast");
}
if (results.value == 3890407325) {
Serial.println("play/pause"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011298483) {
Serial.println("play/pause fast");
}
if (results.value == 291812799) {
Serial.println("center button"); //change this line to make it do whatever you want when that button is pressed
}
if (results.value == 2011249331) {
Serial.println("center button fast");
}
}
Feb 6, 2014, 7:41:42 PM
Posted to A Multi-Protocol Infrared Remote Library for the Arduino

