Arduino with Infra Red remote - Decode Test

Contributor
Submitted by CAAadmin on Sat, 09/24/2016 - 12:12
arduino ir remote

IRemote library can be downloaded from https://drive.google.com/file/d/0B-H_CXR7-MD9QkR1NXNQdUFqdGs/view?usp=sharing

Do not forget to remove the RobotIRemote  library from the root / library folder of arduino

Also try with serial monitor to check the pressed keys and switch cases (below program) are matching.

Connect receiver pin to 11 (hold like a transistor, then right pin out of 3 pins as left pin is –ve and middle one is +ve)

Run this program and press the keys on the remote, and check the serial monitor. If you are using different hardware versions (remotes), use this program to check if the assigned values are correct or not.

 

//*****ARDUINO-CODE-BEGINS****//

#include "IRremote.h"

int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11

IRrecv irrecv(receiver);           //

decode_results results;            //

void setup()  

{

  Serial.begin(9600);

  Serial.println("IR Receiver Raw Data Decode Test");

  irrecv.enableIRIn();

}

void loop()

{

  if (irrecv.decode(&results)) // have we received an IR signal?

  {

    translateIR();

    irrecv.resume(); // receive the next value

  } 

}

 

void translateIR()

{

  switch(results.value)

  {

  case 0xFFA25D:  //exit

    Serial.println(" EXIT            ");

    break;

  case 0xFF629D: 

    Serial.println(" CH             ");

    break;

  case 0xFFE21D:  //menu

    Serial.println(" Menu            ");

    break;

  case 0xFF22DD:  //test

    Serial.println(" TEST           ");

    break;

  case 0xFF02FD:  //+

    Serial.println(" NEXT           ");

    break;

  case 0xFFC23D:  //undo

    Serial.println(" undo     ");

    break;

  case 0xFFE01F:  //back

    Serial.println(" VOL-           ");

    break;

  case 0xFFA857:  //play

    Serial.println(" play           ");

    break;

  case 0xFF906F:  //forward

    Serial.println(" EQ             ");

    break;

  case 0xFF6897: 

    Serial.println(" 0              ");

    break;

  case 0xFF9867:  //-

    Serial.println(" delete           ");

    break;

  case 0xFFB04F:  //c

    Serial.println(" Cancel           ");

    break;

  case 0xFF30CF: 

    Serial.println(" 1              ");

    break;

  case 0xFF18E7: 

    Serial.println(" 2              ");

    break;

  case 0xFF7A85: 

    Serial.println(" 3              ");

    break;

  case 0xFF10EF: 

    Serial.println(" 4              ");

    break;

  case 0xFF38C7: 

    Serial.println(" 5              ");

    break;

  case 0xFF5AA5: 

    Serial.println(" 6              ");

    break;

  case 0xFF42BD: 

    Serial.println(" 7              ");

    break;

  case 0xFF4AB5: 

    Serial.println(" 8              ");

    break;

  case 0xFF52AD: 

    Serial.println(" 9              ");

    break;

  default:

    Serial.println(" other button   ");

  }

  delay(500);

}

//*****ARDUINO-CODE-ENDS****//

Tags