Help please with IR remote control.

Hi,

I need help please with the IR remote control routine. So far I can get the key values from only one IR remote control. However, when I tried with a universal remote control and many others and I can't get any values from all those.

The IR receiver is attached to Arduino's pin 12. This is the code I am using:

#include <IRremote.h>
int device = 0;
int command = 0;

int RECV_PIN = 12;   //set to pin connected to IR decoder

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  
  if(getIR()) {
    Serial.print("device number  ");
    Serial.println(device);
    Serial.print("key code   ");
    Serial.println(command);
    Serial.println();
  }
}


boolean getIR() {
  boolean valid = 0;
  if (irrecv.decode(&results)) {    
    device =  results.value >>24; 
    command = lowByte(results.value - device);  //evaluates to 147 
    irrecv.resume(); // Receive the next value 

    if (device == 28) {   // 28 is decimal for 1C of 1C E350AF
      valid = 1;
    }
    else(valid = 0);
  }
  return (valid);
}

I need to make it work with the universal IR remote control. What am I doing wrong?

Sounds like you have not selected the right device code in your universal remote.

why not print out results.value via serial and debug from there...

Use the IR Dump example sketch to find out the device codes for your universal remote. The device codes may be different depending on the device selected on the universal remote. In other words, the device code for a VCR will be different from the code for a TV. Then put the device code here: if (device == 28) { // 28 is decimal for 1C of 1C E350AF.

Hello sir,

i am working on project " IR remote controlled 6 switches". but, for convenient i am doing by any TV remote.

means, if i pressed power button of any TV remote then it will turn on 1st switch only and if pressed again then turn off.

so my 6 switches are correspond to following button of any TV remote(any means most of famous TV);-

1.power
2.mute
3.channel up
4.channel down
5.volume up
6.volume down

Now, for this as you got , i need list of this six button IR hex code for all famous TV brands.

So, please help me to find these code list else tedious work is to collect all remote , decode them and use them.
But, why reinvent wheel, if it is already invented by someone.

I may pay for list too.

@jeny
I think the previous post to yours provides the best answer. Get a unversal remote and capture them for yourself, at least to prove the concept, for TVs you have access to.

If its going to be a commercial product, proceed with caution & contact one of the main players to purchase their database.

There are some sites that have 'open' IR codes databases.

Try searching for LIRC and also remotecentral.com & hi-firemote.com

Its a lot of work to get a comprehensive database. If its a student project, might be a good idea to limit the scope.

I tried to understand LIRC and also remotecentral.com & hi-firemote.com, but confused....

Ok, few basic i need to be clarified from you,

1.Is any IR protocol based remote buttons have unique IR hex code, eg LG TV power button gives me hex code 20DF10EF and it was also same as in LIRC database, is it unique among other TV brand power button?

2.Is all LG brand TV controlled via any LG TV remote? means i will decode one remote of any LG TV and expecting, it will work on most of LG TV.

How to extract code from LIRC?

1.Is any IR protocol based remote buttons have unique IR hex code, eg LG TV power button gives me hex code 20DF10EF and it was also same as in LIRC database, is it unique among other TV brand power button?

It should be, but not guaranteed.

2.Is all LG brand TV controlled via any LG TV remote? means i will decode one remote of any LG TV and expecting, it will work on most of LG TV.

No

How to extract code from LIRC?

You need to study it...

Search for "sb projects IR"....its agreat site that will explain a lot about the make up of IR signals. You will be able to answer your questions above, after doing some research there.