I am an Arduino (and C/C++) newbie so apologies if I am missing something obvious.
I am using IRremote (github link) as my IR library.
I can get the simple send and receive demos working individually.
However, I cannot get send AND receive working in the same Arduino at the same time.
I do not wish to do something like the "IRrecord" example but what I do want to do is have Arduino send and receive at all times and then trigger alarm/LED once the "beam" is broken.
I am using a TSOP 22 series as my IR receiver. I have tried to use protothreads but no luck. Any tips appreciated.
My current code snippet:
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
Serial.println("IR Receiver... Started");
}
void loop() {
//single threaded nature seems to break below
// i want to start receiver here
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
//delay(5000);
//trying to send here
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12);
Serial.println("Sent Sony......");
delay(40);
}
//delay(5000); //5 second delay between each signal burst
}