Arduino Forum

Using Arduino => General Electronics => Topic started by: jochenv on Mar 26, 2015, 05:55 pm

Title: infrared LED doesn't seem to light up
Post by: jochenv on Mar 26, 2015, 05:55 pm
hallo,
i´m trying to control an air-conditioning system from daikin using a meg2560. i managed to read the IR code, now i´m trying to send it using the attached sketch. it seems to run fine, i get the test-text on the serial but the led itself doesn´t light up. it is connected via a resistor between ground an pin D3. after testing with my mobile i replaced the IR with a regular LED but that also stays dark so i suspect i´m having a problem in the sketch itself.
thank you very much for any useful comment:-)
jochen

Code: [Select]


int IR_led  = 3;


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

}
void pulseIR (long microsecs)
{
}
void loop()
{
  Serial.println("loop");



  //Daikin ON
  Serial.println("ON");

  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(1240);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(1240);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(1240);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);



  delay (1000);



  //Daikin OFF
  Serial.println("OFF");

  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(1240);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(1240);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(1240);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(1220);
  pulseIR(460);
  delayMicroseconds(1240);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(460);
  delayMicroseconds(380);
  pulseIR(440);
  delayMicroseconds(400);
  pulseIR(440);


}

Title: Re: infrared LED doesn't seem to light up
Post by: AWOL on Mar 26, 2015, 06:34 pm
You don't appear to ever write to the pin the LED is connected to.

Also, before you wear-out your keyboard, please find out about arrays and loops.
Title: Re: infrared LED doesn't seem to light up
Post by: JimboZA on Mar 26, 2015, 06:38 pm
The function pulseIR() is empty... so although you're calling it, it does nothing.

Code: [Select]
void pulseIR (long microsecs)
{
}


Have a look at this example at adafruit (https://learn.adafruit.com/ir-sensor/making-an-intervalometer). About half-way down, you'll see code inside that function that creates a 38kHz carrier. If yours isn't 38kHz (some aren't), then you just adjust the delayMicroseconds() for the high ands lows.

Title: Re: infrared LED doesn't seem to light up
Post by: MarkT on Mar 26, 2015, 06:39 pm
Perhaps this:
Code: [Select]
void pulseIR (long microsecs)
{
}

should be a bit more like:
Code: [Select]
void pulseIR (long microsecs)
{
  digitalWrite (IR_led, HIGH) ;
  delayMicroseconds (microsecs) ;
  digitalWrite (IR_led, LOW) ;
}
Title: Re: infrared LED doesn't seem to light up
Post by: jochenv on Mar 26, 2015, 10:52 pm
Thanks very much all of you for your comments. Seems I have a lot to learn:-)
Title: Re: infrared LED doesn't seem to light up
Post by: jochenv on Mar 26, 2015, 10:54 pm
Although, until now, I thought the PulsIR function was talking to the LED. As I said, a lot to learn...