Home Arduino Arduino infrared receiver example

Arduino infrared receiver example

by iainhendry

An infrared receiver, or IR receiver, is a device that sends information from an infrared remote control to another device by receiving and decoding signals.

Basically, the receiver outputs a specific code to identify the infrared signal that it receives. This code is then used in order to convert signals from the remote control into a format that can be understood by the other device lets say your television, so if you press the on button on the remote the reciever will decode that and the television you want to control will switch on. So the infrared receiver is the part of a device that receives infrared commands from a remote control.

Here is a commonly used example of an IR receiver

vs1838

And here it is in module format, you can see you can also get an IR emitter as well. More on that later

ir emitter and reciever
Of course that’s little use on its own and you will also need a little remote control, you can use your own but here is one that is commonly found in Arduino kits

400px-Remote_control

Parts Required

Arduino and USB cable × 1
Infrared remote control × 1
the infrared receiver module × 1
hookup cables

 

Connection

Arduino GND -> Module pin –
Arduino +5V -> Module PLUS (middle pin)
Arduino Digital pin 11 -> Module S

 

Schematic and Layout

here is a schematic and layout quickly drawn up using Fritzing

arduino and ir receiver_bb

 

arduino and ir receiver_schem

Code

You will need to install the IRRemote library for this to work, in later versions of teh Arduino IDE you can search for this using the library manager and add it but if you want to install it manually it is available from

The code example is simple, open the serial monitor and press a button on the remote, you will then see the code in the serial monitor windows, obviously a more practical example would mean the user would have to interpret these codes and perform some sort of action

[codesyntax lang=”cpp”]

#include <IRremote.h>
 
int RECEIVERPIN = 8;
 
IRrecv irrecv(RECEIVERPIN);
 
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(); // Receive the next value
  }
}

[/codesyntax]

 

Links

This kit gives all you need for under $2
Infrared IR Wireless Remote Control Module Kits For Arduino Wholesale

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More