IR transmitter not working

So I have this IR transmitter
ir
and I found interesting to control my TV with this transmitter. I got the hex codes from my remote TV control using an ir receiver and I put the volume up code in this sketch:

#include <IRremote.h>

IRsend irsend;

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

void loop() {
  for (int i = 0; i < 50; i++) {
    irsend.sendNEC(0xFD02FB04, 32);
    delay(300);
  }
}

I connected the transmitter's negative leg with my Arduino's GND and the positive leg to the Arduino's pin 3 (that's what I saw from the tutorial I was watching). Also between the positive leg and pin 3 I placed two 220 Ohm resistors in parallel so the total resistance is 110 ohms. That's what the circuit looks like:

After uploading my code I placed the IR transmitter next to my TV's IR receiver but nothing happened. I also tried to check the transmitter with my phone's camera but I didn't see any light, like when I do it with my TV remote.

I'm sure the IR transmitter works because I did a project where I could find the distance of an object using the same transmitter and an IR receiver.

And how your arduino knows about led connected to pin 3?

That's what I was thinking but that's what the guy on the tutorial did. Also, there were no comments saying how does the arduino know in what pin the led is connected. All the comments were saying thank you, you solved my problem etc.

There is lot of garbage online...
Try some example code from that library you use.

The library default send pin is 3 on AVR boards.

@thanasisk09
Many IR transmitters needs a current that exceeds the maximum of arduino pin, so is probably that you need a transistor driver to power the transmitter.
Also I recommend to see the library examples, because your code is not looks complete.

Ahh, my "mistake".

1 Like

Yeah, I think you are right because the example is very far from the sketch I saw online

Also note, when driving led directly from pin at <40mA, you don't get long range.

That's a possibility too. I will make a research online. The code I found online is the problem.

Yes I know. When I try to make a communication between the led and the TV I place them so close so they touch eachother

Did you know there is a begin() call?
irsend.begin();
Did you try the SendDemo?

Is this what it should look like?

#include "IRremote.h"

IRsend irsend(3);

void setup() {
    Serial.begin(9600);
    irsend.begin();
    irsend.enableIROut(1000);
}

void loop() {
    for (int i = 0; i < 50; i++) {
        irsend.sendNEC(0xFD02FB04, 32);
        delay(300);
    }
}

There are so many IR libraries and versions online, that's why I recommended example from your library installed.

Did you control, longer led leg to +

3 is a Default, pre-defined --

 * Pin mapping table for different platforms
 *
 * Platform     IR input    IR output   Tone      Core/Pin schema
 * --------------------------------------------------------------
 * DEFAULT/AVR  2           3           4         Arduino

Yes. I think the problem is in the code. I will find another one online because the example is too complex. Do you know what resistance I should use for the IR receiver? I don't want to damage anything because the first site I saw didn't use any resistors in it's circuit diagram.

It's ok what you have. I suggest to get a transistor to drive your led. With that you can extend your range a lot.

I will try that. But because I'm new to this field I'm not sure if I will cause any damage by not using any resistors in the IR transistor.

First make it work like that. Later with transistor.
Did you control your led legs?

Certain the IRED is the right way round?

Um, can you please explain what you mean, I'm new and I didn't get that...