Go Down

Topic: infrared LED doesn't seem to light up (Read 814 times) previous topic - next topic

jochenv

Mar 26, 2015, 05:55 pm Last Edit: Mar 26, 2015, 05:58 pm by jochenv
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);


}


AWOL

#1
Mar 26, 2015, 06:34 pm Last Edit: Mar 26, 2015, 06:36 pm by AWOL
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.

JimboZA

#2
Mar 26, 2015, 06:38 pm Last Edit: Mar 27, 2015, 03:34 am by JimboZA
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. 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.

Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

MarkT

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) ;
}
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

jochenv

Thanks very much all of you for your comments. Seems I have a lot to learn:-)

jochenv

Although, until now, I thought the PulsIR function was talking to the LED. As I said, a lot to learn...

Go Up