ArduinoIR remote library modification to include interrupt

Just a quick update today, messing with a little project and I did a performance test on the ArduinoIR library, it is very slow taking 2ms to poll the IR pin so I figured why not just include an interrupt and trigger the polling of the pin using the pin! simple fix and removes the 2ms lagg from the program loop while avoiding missing any button presses!

of course you will need the ArduinoIR library to do this. You can get it here.
The below will output the IR code HEX to your serial pin. It’s basic but does the job without holding up the program loop!

#include <IRremote.h>

int RECV_PIN = 2;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  attachInterrupt(0,CHECK_IR,CHANGE);
  irrecv.enableIRIn(); // Start the receiver

}

void loop() {
 delay(500);
}

void CHECK_IR(){
  while(irrecv.decode(&results)){
  Serial.println(results.value, HEX);
  irrecv.resume();
  }
}


Share

Tags: , , , ,

One Response to “ArduinoIR remote library modification to include interrupt”