Please HELP! My IR Led doesn't work on PIN 3 (D3)

I am using Ken shirriffs library for IR. I'm using a standard Arduino Uno but I can't make my led to work.

I have checked diffrent PIN (9,13,5) to see if PIN 3 was wrong but nothing.

I want to send "irsend.sendNEC(0x10EF, 32);" but it won't work on PIN 3.. please help!!

use your phones camera to see that the LED emits light

How did you figure it's not working? Your device isn't responding? Or did you do some measurements?

I am checking with Serial Monitor and it sends out "0" all the time.. but if I change the function

irsend.sendNEC(0x10EF, 32); into a comment like //irsend.sendNEC(0x10EF, 32);

then my PIN 3 sends out "1" all the time..

"I am checking with Serial Monitor " Can you elaborate on this? And show your code?

I am using Ken shirriffs ir Library.

And are the functions I am using.

void IRsend::sendNEC(unsigned long data, int nbits)
{
enableIROut(38);
mark(NEC_HDR_MARK);
space(NEC_HDR_SPACE);
for (int i = 0; i < nbits; i++) {
if (data & TOPBIT) {
mark(NEC_BIT_MARK);
space(NEC_ONE_SPACE);
}
else {
mark(NEC_BIT_MARK);
space(NEC_ZERO_SPACE);
}
data <<= 1;
}
mark(NEC_BIT_MARK);
space(0);
}

void IRsend::enableIROut(int khz) {
// Enables IR output. The khz value controls the modulation frequency in kilohertz.
// The IR output will be on pin 3 (OC2B).
// This routine is designed for 36-40KHz; if you use it for other values, it's up to you
// to make sure it gives reasonable results. (Watch out for overflow / underflow / rounding.)
// TIMER2 is used in phase-correct PWM mode, with OCR2A controlling the frequency and OCR2B
// controlling the duty cycle.
// There is no prescaling, so the output frequency is 16MHz / (2 * OCR2A)
// To turn the output on and off, we leave the PWM running, but connect and disconnect the output pin.
// A few hours staring at the ATmega documentation and this will all make sense.
// See my Secrets of Arduino PWM at http://arcfn.com/2009/07/secrets-of-arduino-pwm.html for details.

// Disable the Timer2 Interrupt (which is used for receiving IR)
TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt

pinMode(TIMER_PWM_PIN, OUTPUT);
digitalWrite(TIMER_PWM_PIN, LOW); // When not sending PWM, we want it low

// COM2A = 00: disconnect OC2A
// COM2B = 00: disconnect OC2B; to send signal set to 10: OC2B non-inverted
// WGM2 = 101: phase-correct PWM with OCRA as top
// CS2 = 000: no prescaling
// The top value for the timer. The modulation frequency will be SYSCLOCK / 2 / OCR2A.
TIMER_CONFIG_KHZ(khz);
}

And how are you "checking it with the serial monitor"

I can't seem to upload a image of it... Sorry this is my first post and I am really newbie at this..

..can you see light from this led? (when sending data)

Nope I can't..

  1. I don't see anywhere in the code you included that would send any data to Serial, so I don't understand the "0" you're seeing. You should include the code that prints to Serial, or people won't know what the "0" means.
  2. When you say "PIN 3 sends out "1" all the time", does that mean that you measure 5v on pin 3 or what?
  3. Does the IR LED not light? And you know that you can't see an IR LED with your bare eyes? Can you replace the IR LED with a regular LED and check to see if it lights up?
  4. Did you remember the 100 ohm resistor on the LED? Without that, you could mess up Pin 3.
  5. Your send command says to send 32 bits, but only defines a 16 bit value.

I don't think he is sending anything to Serial, I think he is trying to use the serial input to monitor pin 3, which won't work for a variety of reasons.

Yeah Sorry about that I will try to make this post as right as I can.

#include <IRemoteInt.h>
#include <IRremote.h>

IRsend irsend;

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

void loop() {
irsend.sendNEC(0x10EF, 32); // LG TV power code
delay(40);
}

With just this small code I try to see if the tv is working with the led.

  1. What I meant with "0" and "1" is as you said, I was checking to see if my PIN 3 was able to send out data.
    3.I replaced the IR LED with an regular LED on PIN 3 and it worked just fine. So PIN 3 is working just fine.
    4.I connected the 100 ohm resistor as it was shown on one of his examples(Ken)
  2. 32 bit value? You mean irsend.sendNEC(0x10EF, 32)?...Should I change 0x10EF,32 to 0x10EF,16? I Believe I've done that in earlier tests, and it didn't work out, but I will do this. But I am wondering if I am using the right pin.. Cause in his lib he is defining alot of cards, meaning depending on the card(microcontroller) the OUTPUT PIN changes..In this library, I can't seem to find a

#define that specifies my microcontroller(Arduino UNO)

UPDATE: It seems that my IR LED is working(Checked trough my phone) but it still won't activate my TV. Not really sure why..cause in people say in other example that this is how you do it.

If you cant see light (using camera on your smartphone), the diode isnt sending!!
Increase current to led and be sure it can light up.

OK, so it sounds like the circuit is "working", just not the right code. Where did you get "irsend.sendNEC(0x10EF, 32)" for your TV. A friend of mine has an LG TV also (from your comment), and the code we got from IR Receive was completely different, although it was the NEC protocol. BTW, we never got it to work right.
IR LEDs take a lot of current. I added a transistor to mine. Or you probably need to make sure that you're close to the TV's receiver.

And looking at the code again, you're sending the code to the TV continuously. This may overwhelm the TV's input, cause you basically telling the TV to turn on and off many times a second. Try sending the command just once.

A friend of mine has an LG TV also (from your comment), and the code we got from IR Receive was completely different, although it was the NEC protocol. BTW, we never got it to work right.

I just checked an LG remote & it is the same as NEC, but with one important difference.

The first mark (Header or lead-in) is 4500 uSecs long vs 9000 uSecs long for the standard NEC protocol.

3 options:

  1. Change the NEC header definition in the library from 9000 to 4500 uSecs
  2. Use RAW mode to send the signals
  3. Use the NECx protocol in the IRLib library, instead

Thanks! I will try this later when I can. In school right know and haven't sleept in like 19 hours.

Will update how it goes.

You guys are the fucking best putting up with this, and helping me!!

1.I don't see a way to change the NEC definition in the library

2.The frequency I am using to send power to my tv is

POWER ON/OFF

Decoded NEC: 20DF10EF (32 bits)
Raw (68): -31004 9000 -4350 600 -500 600 -550 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -550 550 -1700 550 -1650 550 -550 550 -1650 550 -1700 500 -1700 550 -1650 550 -1650 550 -550 550 -550 550 -600 550 -1650 550 -550 550 -550 550 -550 550 -550 550 -1700 500 -1700 550 -1650 550 -550 550 -1650 550 -1700 550 -1650 550 -1650 550

This is the RAW frequency.. do you want me to change the 9000 in it to 4500 ?

  1. I don't understand what you mean with NECx... Sorry.

Ohgodpleasecompile:
Decoded NEC: 20DF10EF (32 bits)

If this raw signal is the one you captured from your remote using IRremote then the folloding code should work for you.

irsend.sendNEC(0x20DF10EF, 32); // AnalysIR IR Protocol: NEC, Key: