I spoke too soon.
The code works perfectly as used in
//Turn Samsung TV on/off repeatedly to test program.
//IR LED connected to pin 3.
#include <IRremote.h>
unsigned int power[] = {4550,4400,600,1650,550,1650,600,1650,
550,550,600,500,600,550,550,550,600,500,600,1650,600,1600,600,
1650,550,550,600,500,600,550,600,500,600,500,650,450,650,1600,
600,500,650,450,650,500,600,500,600,500,600,550,600,1600,600,
500,650,1600,650,1550,650,1600,650,1550,650,1600,650,1600,600};
IRsend irsend;
void setup()
{
pinMode (3, OUTPUT); //output used in library
}
void loop() {
irsend.sendRaw(power,68,38);
delay (5000);
}//end of loop
But not when used with receiving a signal from the remote. My long sketch reads the input from the remote and does actions dependent on the key pressed. It all worked correctly until I added the irsend.sendRaw statement in a function.
I have removed all of the program that is not relevant to the problem and have this code.
#define power 0xE0E040BF //for receiver
#include <IRremote.h> // http://arcfn.com
//raw data for IR Tx;
unsigned int powerIRout[] = {
4550,4400,600,1650,550,1650,600,1650,550,550,600,500,
600,550,550,550,600,500,600,1650,600,1600,600,1650,550,550,600,500,600,550,
600,500,600,500,650,450,650,1600,600,500,650,450,650,500,600,500,600,500,600,
550,600,1600,600,500,650,1600,650,1550,650,1600,650,1550,650,1600,650,1600,600};
IRrecv irrecv(11);
decode_results results;
IRsend irsend;
void setup () {
Serial.begin (9600);
irrecv.enableIRIn(); // Start the IR receiver
pinMode (3, OUTPUT); //IR LED
}
void loop (){
if (irrecv.decode(&results)) //read IR
{
sendIR ();
}
irrecv.resume(); // Resume decoding (necessary!)
delay (200);
}
void sendIR () //function to output "POWER" code to IR diodes.
{
Serial.println ("send IR out");
irsend.sendRaw(powerIRout,68,38);
Serial.println ("sent");
}
The function sendIR works once then locks up, reset needed to repeat. Comment out the irsend.sendRaw line and it works repeatedly each time I press the remote.
It appears that the irsend interferes with the irreceive.
The basic code was derived from the examples in the library.
Your assistance would be appreciated.
weedpharma