hi.
i’m trying to build a project that recieve IR codes from remote controls, which identify 4 specific commands
(marked as RED,BLUE,GREEN,YELLOW), and upon recieving RED it should transmit a constatnt transmission.
the problem is that it can recieve without bugs, but after it transmit it doest recieve anymore.
i attached an example output (see image), from that point on no other input can be recieved.
CODE:
#include <IRremote.h>
int RECV_PIN = 2;
int flag = 0 ;
unsigned long int RED = 3205937430;
unsigned long int GREEN = 61353670;
unsigned long int YELLOW = 2684089140;
unsigned long int BLUE = 3781012030;
int i;
decode_results results;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();// Start the receiver
}
void loop() {
unsigned long int n;
flag = 0;
if (irrecv.decode(&results)) {
n = results.value;
Serial.print(" recieved: ");
Serial.print(n);
Serial.print(" of type: ");
Serial.print(results.decode_type);
Serial.print(" num if bits: ");
Serial.print(results.bits);
if (n == RED) {Serial.print(" RED "); flag = 1; }
if (n == GREEN) {Serial.print(" GREEN "); flag = 2;}
if (n == YELLOW) {Serial.print(" YELLOW "); flag = 3;}
if (n == BLUE) {Serial.print(" BLUE "); flag = 4;}
Serial.print("\a\n\n");
//SPECIAL CASE:
if (flag == 1) {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90,32);
delay(100);
Serial.println(" sent succesfully \n");
}
}
// Receive the next value
irrecv.resume();
}
}
thx.
output: