Reading IR with an Arduino

It’s really simple! We’ll use the following library from Rafi Khan:

https://github.com/z3t0/Arduino-IRremote

Then we need a microcontroller like an Arduino UNO and an IR receiver module.
I’m using the KY-022 IR receiver module from AZdelievery. You can get it here.

Also wiring is not a big deal:

ir receiver wiring with an Arduino

The sketch is really simple:

#include <Arduino.h>
#include <IRremote.h>

const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
}

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

Voila… ready any ir remote!

Share

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *