Arduino Xinda / Keyes Infrared Remote Tutorial

Simple to implement Arduino IR Remote Control

Keyes Xinda IR Remote Control KitThese remote controls are incredibly inexpensive and are pretty simple to use.

They consist of a key pad that transmits and IR signal and an IR receiver that connects to your Arduino.

The kit is generally billed as having either the HX1838 or VS1838 IR sensor.  It requires only three connections and is easily implemented with a readily available library.

Applications basically limitless.

Where to Find the IR Receiver

The device will generally carry a Xinda or Keyes label on its key pad.   It is easily found on any of these sites:

eBay     Amazon     Banggood     Fast Tech

Xinda / Keyes Infrared Receiver Pin-outs

The only connections you will require are a power, ground and a signal input to your Arduino

Arduino Xinda Remote Control Module

 

Arduino Keyes / Xinda IR Remote Control Tutorial

Get the IRRemote.h Library

The necessary library can be found here on GitHub.   If you’re not familiar with working with libraries,  you can learn about it here.

NOTE:   Some versions of your Arduino software included a library that will conflict with the above library.   It is in a directory called RobotIRremote.  It can be found in the Program Files (x86)/Arduino/libraries/ directory.   You will want to move this RobotIRremote directory in order to prevent conflicts.

MoveXinda

When I do this,  I usually move to a directory I created called library storage.  It makes it a little easier to find later if I want it.

Connect Up for Arduino IR Remote Control.

The connections are simple.

Arduino Xinda Remote Tutorial Connections

Copy, Paste and Upload the IR Remote Tutorial Code Part 1

The sketch below simply receives a signal and shows the value of the signal received on your serial monitor.

//  Henry's Bench IR Remote Tutorial 1

#include <IRremote.h>

int IR_PIN = 11;

IRrecv irDetect(IR_PIN);

decode_results irIn;

void setup()
{
  Serial.begin(9600);
  irDetect.enableIRIn(); // Start the Receiver
}

void loop() {
  if (irDetect.decode(&irIn)) {
    Serial.println(irIn.value, HEX);
    irDetect.resume(); // Receive the next value
  }
}

Verify The Part 1 Tutorial Output

Depending on the keys pressed,  your output should look something like the screen grab below:

Arduino Xinda IR Remote Tutorial Part 1 Output

Output Key Value Table

If you examine your output,  you will see that a valid key value is a 3 byte Hex value or is “FFFFFFFF”.   Thus what it will be important to map the values to the keys of interest.

Below are the values that I mapped to MY REMOTE.  I emphasize this because I have no idea what the next wave of these Chinese devices will bring.

KeyValue
Up ArrowFF629D
Left ArrowFF22DD
OKFF02FD
Right ArrowFFC23D
Down ArrowFFA857
1FF6897
2FF9867
3FFB04F
4FF30CF
5FF18E7
6FF7A85
7FF10EF
8FF38C7
9FF5AA5
*FF42BD
0FF4AB5
#FF52AD

Copy, Paste and Upload the IR Remote Tutorial Code Part 2

In this sketch, I put the knowledge about the key values to use.   Once the an input has been received,  I call out to decodeIR() and decipher the value.

//  Henry's Bench IR Remote Tutorial 2

#include <IRremote.h>

int IR_PIN = 11;

IRrecv irDetect(IR_PIN);

decode_results irIn;

void setup()
{
  Serial.begin(9600);
  
  irDetect.enableIRIn(); // Start the Receiver
}

void loop() {
  if (irDetect.decode(&irIn)) {
    decodeIR();
    irDetect.resume(); 
  }
}

void decodeIR() // Indicate what key is pressed

{

  switch(irIn.value)

  {

  case 0xFF629D:  
    Serial.println("Up Arrow"); 
    break;

  case 0xFF22DD:  
    Serial.println("Left Arrow"); 
    break;

  case 0xFF02FD:  
    Serial.println("OK"); 
    break;

  case 0xFFC23D:  
    Serial.println("Right Arrow"); 
    break;

  case 0xFFA857:  
    Serial.println("Down Arrow"); 
    break;

  case 0xFF6897:  
    Serial.println("1"); 
    break;

  case 0xFF9867:  
    Serial.println("2"); 
    break;

  case 0xFFB04F:  
    Serial.println("3"); 
    break;

  case 0xFF30CF:  
    Serial.println("4"); 
    break;

  case 0xFF18E7:  
    Serial.println("5"); 
    break;

  case 0xFF7A85:  
    Serial.println("6"); 
    break;

  case 0xFF10EF:  
    Serial.println("7"); 
    break;

  case 0xFF38C7:  
    Serial.println("8"); 
    break;

  case 0xFF5AA5:  
    Serial.println("9"); 
    break;

  case 0xFF42BD:  
    Serial.println("*"); 
    break;

  case 0xFF4AB5:  
    Serial.println("0"); 
    break;

  case 0xFF52AD:  
    Serial.println("#"); 
    break; 

  default: 
   break;

  }

  

Verify Your Tutorial Output

Open the serial monitor.   Press the keys.  You should notice that the serial monitor reports exactly which key you pressed.

That said,  it might take a little practice pressing the buttons.  Mine acted a little finicky as first.