Hi,
In my current project, I have a garage door opener sending codes to a 433 MHz RF receiver. While the program is running, if I press any of the 4 buttons on the remote, the serial monitor shows the correct "rfscene", from 0-3.
After a little while however, several seconds/inputs. The serial monitor stops showing data altogether, no matter how often/slow/long/short I press the remote button.
Code below, please advise if you have a suggestion.
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int rfscene = 0;
int rfDelay; //used to delay how often rfscene is output to serial monitor
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #D2
}
void loop() {
if (mySwitch.available()) {
unsigned long int rfvalue = mySwitch.getReceivedValue();
//Serial.print(rfvalue);
switch(rfvalue){
case 11302456: mySwitch.disableReceive();
rfscene = 0;
break;
case 11302449: mySwitch.disableReceive();
rfscene = 1;
break;
case 5408930: mySwitch.disableReceive();
rfscene = 2;
break;
case 11302450:mySwitch.disableReceive();
rfscene = 3;
break;
}
Serial.print(rfscene);
rfDelay=millis();
while(millis()<rfDelay+500){}
mySwitch.resetAvailable();
mySwitch.enableReceive(0);
}
}