IR receiver reads 0

Hi peoples :slight_smile:

I couldn't find specified problem so decided to write a new topic,
hopefully in the right place.

So anyway, I am having a hard time trying to send ir code from LED to the receiver.
When using small remote that came with it, I can read values in HEX no problem.
But when I try to send a value from the LED it always shows the value at 0 and nothing happens.
Sure the receiver is wired right as it reads the remote HEX.

The problem must be in the LED emitter.
I have it connected - to ground in Arduino and + to output 4 (tried 5 with same result).
There is an 330kOhm resistor on the + of the LED.

Screenshot of code and serial window are attached.

I'm new to Arduino so please understand and forgive me if it's a simple mistake :slight_smile:
Happy to work on some projects in the future and welcome to the forums !

330K is way too much for a LED.

Try 220 ohm.
Make sure you have the cathode of the LED going to GND.

Edit
Have you seen this:
https://learn.sparkfun.com/tutorials/ir-communication
.

Thanks for your answer.
I had a good read of that tutorial.
I put 220Ohm resistor instead, and changed the code.

#include <IRremote.h>

int IR_PIN = 4;

IRrecv irDetect(IR_PIN);
decode_results irIn;
IRsend irsend;

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

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

void sendSony() { for (int i = 0; i < 3; i++) {
    irsend.sendSony(0x640C, 15); //Sony vol-
    delay(40);
    decodeIR();
    irDetect.resume(); 
  }
  delay(2000);
}
void decodeIR() // Indicate what key is pressed

{
  Serial.println(irIn.value);
}

Its very strange as sending works on my Sony home cinema but its still showing 0.
I think that line always reads 0 for some reason:

  Serial.println(irIn.value);

But I have the same line in a separate receive program and it reads proper HEX.
Would be nice to figure it out but at least it works now.