Order yours here
Description:
Infrared receiver module uses a 1838 infrared receiver. This is a universal type, with steel, bendable legs.
Size: 6.4 * 7.4 * 5.1MM, acceptance angle 90 °, working voltage 2.7-5.5V.
Frequency 37.9KHZ, receiving distance 18 m.
Daylight rejection up to can 500LUX, electromagnetic interference capability, built-in infrared dedicated IC.
Widely used: stereo, TV, VCR, CD, set-top boxes, digital photo frame, car audio, remote control toys, satellite receivers, hard disk player, air conditioners, heaters, fans, lighting and other household appliances.
Pinout:
Example Arduino Sketch:
Code: Select all
/* FILE: HC_Exp_Kit_IR_Remote_Example
DATE: 03/09/13
VERSION: 0.1
REVISIONS:
18/09/13 Created version 0.1
This is an example sketch which uses the IR remote control (NEC protocol) and IR
receiver module (HCSENS0010) to receive infrared IR codes sent by the remote.
It will then output the name of the button pressed to the UART.
To connect the module to your Arduino please see the following pinout:
PINOUT (Receiver facing towards you):
MODULE ARDUINO
OUT D11
VCC +5V
GND GND
Please note: The HCSENS0010 module reverses the order of the VCC and GND pins.
Make sure you connect these pins in the correct order. You can reference the screen
print on the module, or the diagrams in our forum post here:
http://forum.hobbycomponents.com/viewtopic.php?f=74&p=4901
The example sketch uses the IRremote library written by Ken Shirriff
(http://arcfn.com).
You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used for the purpose of promoting or selling products
that directly compete with Hobby Components Ltd's own range of products.
THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER. */
/* Include the IRremote library */
#include <IRremote.h>
/* Define the DIO pin used for the receiver */
#define RECV_PIN 11
/* Structure containing received data */
decode_results results;
/* Used to store the last code received. Used when a repeat code is received */
unsigned long LastCode;
/* Create an instance of the IRrecv library */
IRrecv irrecv(RECV_PIN);
void setup()
{
/* Configure the serial port to display the received codes */
Serial.begin(9600);
/* Start receiving codes */
irrecv.enableIRIn();
/* Initialise the variable containing the last code received */
LastCode = 0;
}
/* Main program */
void loop()
{
/* Has a new code been received? */
if (irrecv.decode(&results))
{
/* If so get the button name for the received code */
Serial.println(GetIRIndex(results.value));
/* Start recieving codes again*/
irrecv.resume();
}
}
/* Function returns the button name relating to the received code */
String GetIRIndex(unsigned long code)
{
/* Character array used to hold the received button name */
char CodeName[3];
/* Is the received code is a repeat code (NEC protocol) */
if (code == 0xFFFFFFFF)
{
/* If so then we need to find the button name for the last button pressed */
code = LastCode;
}
/* Find the button name for the received code */
switch (code)
{
/* Received code is for the POWER button */
case 0xFFA25D:
strcpy (CodeName, "PW");
break;
/* Received code is for the MODE button */
case 0xFF629D:
strcpy (CodeName, "MO");
break;
/* Received code is for the MUTE button */
case 0xFFE21D:
strcpy (CodeName, "MU");
break;
/* Received code is for the PLAY/PAUSE button */
case 0xFF22DD:
strcpy (CodeName, "PL");
break;
/* Received code is for the REWIND button */
case 0xFF02FD:
strcpy (CodeName, "RW");
break;
/* Received code is for the FAST FORWARD button */
case 0xFFC23D:
strcpy (CodeName, "FF");
break;
/* Received code is for the EQ button */
case 0xFFE01F:
strcpy (CodeName, "EQ");
break;
/* Received code is for the VOLUME - button */
case 0xFFA857:
strcpy (CodeName, "-");
break;
/* Received code is for the VOLUME + button */
case 0xFF906F:
strcpy (CodeName, "+");
break;
/* Received code is for the number 0 button */
case 0xFF6897:
strcpy (CodeName, "0");
break;
/* Received code is for the RANDOM button */
case 0xFF9867:
strcpy (CodeName, "RN");
break;
/* Received code is for the UD/SD button */
case 0xFFB04F:
strcpy (CodeName, "SD");
break;
/* Received code is for the number 1 button */
case 0xFF30CF:
strcpy (CodeName, "1");
break;
/* Received code is for the number 2 button */
case 0xFF18E7:
strcpy (CodeName, "2");
break;
/* Received code is for the number 3 button */
case 0xFF7A85:
strcpy (CodeName, "3");
break;
/* Received code is for the number 4 button */
case 0xFF10EF:
strcpy (CodeName, "4");
break;
/* Received code is for the number 5 button */
case 0xFF38C7:
strcpy (CodeName, "5");
break;
/* Received code is for the number 6 button */
case 0xFF5AA5:
strcpy (CodeName, "6");
break;
/* Received code is for the number 7 button */
case 0xFF42BD:
strcpy (CodeName, "7");
break;
/* Received code is for the number 8 button */
case 0xFF4AB5:
strcpy (CodeName, "8");
break;
/* Received code is for the number 9 button */
case 0xFF52AD:
strcpy (CodeName, "9");
break;
/* Received code is an error or is unknown */
default:
strcpy (CodeName, "??");
break;
}
/* Save this code in case we get a repeat code next time */
LastCode = code;
/* Return the button name for the received code */
return CodeName;
}
The above example sketch uses the IR Remote Library written by Ken Shirriff (http://arcfn.com). A know working snapshot can be downloaded here: