I'm building a sketch which will receive an IR signal and transmit a different IR code. A first version is working perfectly.
Here is the salient portion of the working sketch. All variables are defined and the IRsmallDecoder library is used.
void setup() {
delay(500);
pinMode(LED_BUILTIN, OUTPUT);
pinMode(IRLEDpin, OUTPUT);
digitalWrite(IRLEDpin, LOW);
msPrev = 0;
}
void loop() {
unsigned long msCurr = millis(); //read current milliseconds time
if (msCurr - msPrev >= 3000) { //delay for 3 sec
digitalWrite(LED_BUILTIN, HIGH); // flash LED
delay(100);
digitalWrite(LED_BUILTIN, LOW);
delay(50);
msPrev = msCurr; //reset timer
sendIR();
}
This code works- every 3 seconds the LED flashes and the IR signal is transmitted, via sendIR(). But now, I want to only send the IR if a specific IR code is received and have tried to modify the loop() function.
When I run this code, the LED flashes when the proper IR code is received but the IR signal is never sent (no flashing observed on my cell phone camera). Why?!