Using the Arduino as an IR remote

What I would really like to do is be able to control various devices using infared. I have the on/off times and I figured out how to advance them in arrays, but I can’t find out what I’m missing. I’m basing the code partially off of the tv-b-gone code:

It’s something like (I don’t have the code with me)

long onTime = {( ( (16000000.0 / 37520.0) / 2.0 ) - 1.0), 234, 234, 234 ,234…};
int offTime = {0, 54, 54, 54…};
in irPin = 3;

while (i = 0; i < 36; i++)
digitalWrite(irPin, HIGH);
delayMicroseconds(onTime * 10);
digitalWrite(irPin, LOW);
delayMicroseconds(offTime * 10);
I can see the IR blink extremely fast, but the tv is definately not turning off or on :stuck_out_tongue:
Any ideas?

Most likely your issue is that when the LED is set to logical one it isn’t supposed to be constant. Most likely it’s supposed to be pulsing at the carrier frequency of 38KHz.

I created a sample program for a few devices and posted the code Here.

Good Luck!