1

I have an IR Receiver hooked up to my arduino and a remote with an IR Trasmitter in it. I have some code to decode the values that are received but the values change even when I am pressing the same button!

Here is the code I am using:

#include <IRremote.h>

int IRpin = 8;
IRrecv irrecv(IRpin);
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() 
{
  if (irrecv.decode(&results)) 
    {
      Serial.println(results.value, HEX);
      irrecv.resume();
    }  
}

and here is me pressing the same button 10 times and the output for it:

9C01C8E1
FFFFFFFF
82A6A14C
FFFFFFFF
FFFFFFFF
70D67871
FFFFFFFF
BCB5C227
FFFFFFFF
B358F5ED
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
FFFFFFFF
58EE9A27
FFFFFFFF
90750A0D
FFFFFFFF
FFFFFFFF
FFFFFFFF

6
  • Maybe the hardware is wrong. Can you show your wiring?
    – Nick Gammon
    Dec 31, 2016 at 22:23
  • @NickGammon circuits.io/circuits/3614549-the-unnamed-circuit/… Its a 470 Ohm resistor.
    – user29569
    Dec 31, 2016 at 22:29
  • Which IR receiver do you have? Not all of them require a resistor. See here. Also maybe you have the pins the wrong way around.
    – Nick Gammon
    Jan 1, 2017 at 2:12
  • Try using a different remote...
    – Aamir
    Jan 1, 2017 at 14:46
  • It is not the remote that encodes the signals, it is the IR receiver. Changing the remote would do nothing.
    – user29569
    Jan 1, 2017 at 20:47

2 Answers 2

1

Get TSOP1738 or any good IR receiver to decode. Above code is appropriate and does not need any changes. you will surely get some fluctuations and different decoded hex codes but it would provide only 2 different values for single button so that while controlling any device using ir , you can use 'or' operator in conditional statement and hence you will get desired results. Getting absolute results from a cheap IR receiver is a myth.But it will work well for your project at lower level.I had worked with that and my device is working in my room with no difficulty.

1
  • You were right. The IR receiver that I had isn't yet supported by the IRremote library.
    – user29569
    Jan 1, 2017 at 20:48
1

I eventually figured it out. The IR Receiver that I had was made by a company called Sharp. Every company has different methods of encoding and decoding IR signals, and it just so happens that decoding Sharp messages is not yet supported in the IRremote library, the library I was using for IR communication. I found a different IR receiver from an old electronic device that I had, I tried that and it worked perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.