0

I bought a 37 in 1 sensor kit from Aliexpress.

Now am trying to use the infrared receiver with a TV commander.

My problem is that it returns as result only zeroes. The wiring is right. The code is from an example and includes not much.

I did a serial print to see if the receiver is working. It gives zeroes back so it is working.

I thought maybe a different library will help and downloaded irlib2 library and set the folders into the library folder.

But it can not find it the library so i must use IRremote library.

#include <IRremote.h>

const int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

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

void loop(){
Serial.println(results.decode_type);

Serial.println(results.value, HEX);
if (irrecv.decode(&results)){

    Serial.println(results.value, HEX);
    irrecv.resume();
}
}

What can i do to find what causes the zeroes?

  • My question is the last sentence. What can i do to find what causes the zeroes. – user8886193 Apr 11 '18 at 9:10
  • 1
    When you add a new library you must first put it in the library directory then register it with the IDE by pulling down the menu function "Sketch->Import Library->Add Library - Did you do that with the new library? If not, then that would explain why it couldn't use the new one. – SDsolar Apr 11 '18 at 14:23
  • Have you tried printing the undecoded results? – SDsolar Apr 11 '18 at 14:51
2

I GUESS that it might be because of the following:

  1. You declare results (it will be initialised to zeros)
  2. In loop, you print the results.decodeType (which will be zero)
  3. You then print results.value, which is still zero.
  4. You then call irrecv.decode() which fails for some reason.
  5. The code loops and starts printing lots of zeros.

You need to find out IF irrecv.decode() is failing and if so why. So add an else clause to catch it in the act.

| improve this answer | |
  • It is failling because the value is zero. I tried another library and it did not work too. I thought maybe the commander and testet with a second one with the same result. The sensor has got a built in led and when i press it is blinking. Know what to do? – user8886193 Apr 10 '18 at 12:07
  • Do you know that the irrecv.decode() function is receiving all zeros? What happens if you change the value of results.value before you call decode? – Code Gorilla Apr 10 '18 at 13:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.