Infrared LED not working

i have been trying to get this to work for a week now, but no luck :frowning:

i am following this post here:

i have the IR led setup like this:

here is the photo:
https://drive.google.com/file/d/0B6zxKV5e65QTVkszWW5wbF9MOHc/preview?pli=1

i setup 2 arduino:

uno - with the IR receiver, when it reads, the green led will be on for a sec. and the led does turn on whenever i press any key on any remote. i was able to read a code too, and stored it in mega.

mega - with the IR transmitter, every 3 seconds, it will blink 2 times, then sends out the code... and i see it blinks, and i expect to see green on uno too, but nothing. this is the 2nd led i am trying, in case the 1st happen to be bad.

below is the code on mega, can someone help me please? i am out of troubleshooting ideas :frowning:


#include <IRremote.h>

IRsend irsend;
int LED_PIN = 5;

void setup()
{
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
}

void loop() {
int khz = 38; // 38kHz carrier frequency for the NEC protocol

// FF02FD
unsigned int irSignal[] = {8900, -4400, 600, -500, 600, -500, 600, -500, 550, -500, 600, -500, 600, -500, 600, -500, 600, -500, 600, -1600, 600, -1600, 600, -1600, 600, -1650, 550, -1650, 600, -1600, 600, -1600, 600, -1600, 600, -500, 600, -500, 600, -500, 600, -500, 600, -500, 550, -500, 600, -1650, 550, -500, 600, -1650, 550, -1650, 600, -1600, 600, -1600, 600, -1600, 600, -1650, 550, -500, 600, -1650, 550};

digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(100);
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(100);

digitalWrite(LED_PIN, HIGH);
irsend.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), khz);
digitalWrite(LED_PIN, LOW);

delay(3000); //In this example, the signal will be repeated every 5 seconds, approximately.
}

You should read Topic: Read this before posting a programming question

I do not know which IRRemote library you are using, so I can only guess.

The raw data looks suspicious (I have never seen negative values in them before).

If you know the code (FF02FD) why dont you use that?

Or is that comment as misleading as this:

delay(3000); //In this example, the signal will be repeated every 5 seconds, approximately.

thanks for the note. i am using this lib: GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols

re: neg. values... interesting, i tried a few different remotes, i always get negative values... and i also get different values in the dump too, like sometimes it's -1800, sometimes in -1750 and -1850 etc...

re: using FF02FD... can you point me to an example of using it? all samples i see shows how to get the int[] from the dump, then send them.

thanks again!

ok, got it... like this... irsend.sendSony(0xa90, 12);

thanks!

So basically ALL comments in the above code are rubbish. :cry:

hmm, no luck.

i tried the below code, my uno broad still not reading anything. any other ideas for me to try?

IRsend irsend;

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

void loop() {
  if (Serial.read() != -1) {
    for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa90, 12); // Sony TV power code
      delay(100);
    }
  }
}

http://luckylarry.co.uk/arduino-projects/arduino-redefining-the-tv-remote/

IRsend irsend;

// just added my own array for the raw signal
unsigned int powerOn[68] = {4450,4500,550,1700,500,1750,500,1750,500,600,550,600,500,600,550,600,500,600,550,1700,550,1700,550,1700,500,600,550,600,500,600,550,600,500,650,500,600,550,1700,500,650,500,600,550,600,500,600,550,600,500,600,550,1700,550,600,500,1700,550,1700,550,1700,550,1700,500,1750,500,1750,500};

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

void loop() {

      // altered the code just to send/test my raw code
      irsend.sendRaw(powerOn,68,38);
      delay(100);

}

What protocol is used by the device you want to control?

Where do you copy those raw values from?

What raw signals are transmitted by your existing remote?

You could try something that corresponds to the raw code in your first post (which is a valid NEC code)irsend.sendNEC(0x00FF40BF, 32); // adr 0x00, cmd 0x40
A PDF that describes the basic NEC protocol here Altium
A PDF that describes a couple of protocols here Vishay

Some notes:

The resistor for the led is quite low (allowing 50mA)
it would be safer to use a higher value (220 for 23mA).
If you want to go for power add a transistor or FET stage to drive the led.

The orientation of the transmit-led and the receiver in your setup are perpendicular,
while this probably works next to each other (unstable, via diffusion or reflection) ,
it would be better to have the transmitter pointing to the receiver.
In your setup you can just bend the ir-led so its head points to the receiver.

ahh, i tried the code you mentioned, also bended the ir-led, nothing. :frowning:

ok, so i decided to debug into the irremote library, and found out that for MEGA, it's actually on pin 9 instead of pin 3 like i read from most articles!
https://github.com/z3t0/Arduino-IRremote/blob/master/IRremoteInt.h#L257

i wasalso able to verify that by printing out TIMER_PWM_PIN like below, as well as replacing the IR-led with a GREEN-led, and i see very lite flashes!!

void  IRsend::enableIROut (int khz)
{
	// ** code removed **

	Serial.print("TIMER_PWM_PIN ");
	Serial.println(TIMER_PWM_PIN);

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

	// ** code removed **
}

but the receiver on my UNO broad is still not picking up anything... does anyone know how the TCC, BV and COM works?? and how i can break them down to debug/print to further isolate the issue? thanks!!

#define TIMER_ENABLE_PWM   (TCCR1A |= _BV(COM1A1))
#define TIMER_DISABLE_PWM  (TCCR1A &= ~(_BV(COM1A1)))

Try to check it's resistance with a multimeter. In the event that they are short circuited in both bearings, they are exploded. Put new batteries in the gadget being tried. This guidelines out level batteries and empowers you to check whether the infrared LED is broken or not. For any future resume writing help you can click this site for more details.

A quick tip for testing IR LED's (since you cant see the light)... view the transmitting diode through a mobile phone camera...