Hello everyone,
I have a work project involving IR. I'm suppose to send and receive IR signal with the same arduino. For sending and reciving i'm using the IRremote library, an IR receiver and an IR transmitter.
The library works perfectly when i'm using one arduino to send, and another to receive.
But when I implement the code for both receiving and sendind, I blocks on sending. That's my code
#include <IRremote.h> // Include the library
int RECV_PIN= 11; //Pin of the receiver
IRrecv irrecv(RECV_PIN); // Start the reciever
decode_results results;
IRsend irsend;
int incomingByte=0;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // enables the reciver
}
void loop (){
if(irrecv.decode(&results)){
Serial.println(results.value,HEX); // decodes results
irrecv.resume();
}
if (Serial.available() > 0){
incomingByte= Serial.read(); // if i send 1, start isend
if(incomingByte=49){
isend();
}
}
}
void isend(){
cli();
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(40);
}
sei();
}
Until I don't send 1 to the port com, it receives IR perfectly, but when I send 1 to com, it send an IR signal but does not stop sending it. I would like to send an IR signal for a given time then go back to receiving IR.
Do anyblody has an idea ? My work project is blocked until I find a solution.
Thanks in advance
IR receiver : Gravity: Digital IR Receiver Module - DFRobot
IR transmitter : Gravity: Digital IR Transmitter Module - DFRobot
Arduino used : http://www.zartronic.fr/dfrduino-romeo-robotique-328-rev11-compatible-arduino-p-146.html