This is a quick example showing how to connect an IR Reciever. Most of these work the same way, 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.
Many Ebay, Amazon or other electronic shops online stock breakouts for these. They should cost more than about £2.
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
#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();
}
}
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, we’ll do that in a later write up.