Ok, I need your help! I know posts have been written about interfacing using modulated IR before but I can't remember anything covering the NEC protocol, just Sharp/Sony etc.
From what I managed to gather online, this is the code I have come up with:
int irPin = 13;
int data[32] = {0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,0,1,0,1,0,0,0,0,1,0,1,0,1,1,1};
//int data[32] = {0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,1,1};
void setup()
{
pinMode(irPin, OUTPUT);
}
void loop()
{
//send preamble
oscWrite(irPin, 9000);
delayMicroseconds(4500);
//send data
for(int i = 0; i < 32; i++)
{
//space
oscWrite(irPin, 565);
//data
if(data[i] == 0)
{
delayMicroseconds(560);
}
else
{
delayMicroseconds(1690);
}
}
oscWrite(irPin, 565);
delay(500);
}
void oscWrite(int pin, long time)
{
for(int i = 0; i < (time / 26); i++)
{
digitalWrite(pin, HIGH);
delayMicroseconds(13);
digitalWrite(pin, LOW);
delayMicroseconds(13);
}
}
The data variable contains the signal for sending Mute to my tv and the commented data variable contains Volume Up. I found these by using an IR-demodulator to read the signals off of my remote so I know they should be good.
Still, it does nothing... During my testing the Mute-command worked twice, with no explanation for why! Also, I assume the carrier is good enough, since I wrote a program that uses oscWrite to output a continous carrier and that blocked the TV's remote completely.
Please help!