I am displaying messages on a P10 led panel using DMD2. But I also need to control some functions on this panel using a RF433Mhz remote using RCSwitch.h
But the two together does not work. When I write dmd.begin() the interrupt handler is on and it seems to interrupt the RCSwitch which also uses interrupt, mySwitch.enableReceive(0);
How do I resolve this?
#include <DMD2.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
SoftDMD dmd(1,1);
void setup() {
Serial.begin(115200);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
pinMode(LED_BUILTIN, OUTPUT);
dmd.begin();
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.print("Unknown encoding");
} else {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
Serial.print( mySwitch.getReceivedBitlength() );
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println( mySwitch.getReceivedProtocol() );
}
if (mySwitch.getReceivedValue() == 140160853) {
digitalWrite(LED_BUILTIN, HIGH);
}
if (mySwitch.getReceivedValue() == 140160869) {
digitalWrite(LED_BUILTIN, LOW);
}
mySwitch.resetAvailable();
}
}