Home Code Infrared receiver example

Infrared receiver example

by shedboy71
[lebox id="1"]

In this example we look at how to connect an IR Reciever. Generally, they require Vcc(5v), GND and there is a data out which you connect to your Arduino. Here is a typical IR showing the pinout.

 

IR example

IR example

Many electronic shops online stock breakouts for these.

You’ll need the IR Remote library, you can get this from

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

Download and import or copy into your Arduino -> Library folder. As usual this library will be doing most of the work making it easier for ourselves.

Code
[c]
#include <IRremote.h>

int RECV_PIN = 3;

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();
}
}
[/c]
Testing

I opened the serial monitor and pressed the keys from 0 to 9 here is what was displayed

FF30CF
FF18E7
FF7A85
FF10EF
FF38C7
FF5AA5
FF42BD
FF4AB5
FF52AD
FF6897

As you can see with a bit of programming we can take these values and put them to use.

 

Links

Infrared reciever on Amazon UK

Infrared reciever at Amazon

Share
[lebox id="2"]

You may also like