DMD2 LIBRARY interferes IR REMOTE RECEIVER

I am on a scoreboard project using 2 P10 LED panels with IR Remote Control.

I am using DMD2 library for P10 display and IRremote for the remote control;

I have decoded the remote control through (irrecv.decodedIRData.command) and received the following key codes for each button in decimals:

CH- 69
CH 70
CH+ 71
REWIND 68
FORWARD 64
PLAYPAUSE 67
( - ) 7
( + ) 21
EQ 9
0 22
100+ 25
200+ 13
1 12
2 24
3 94
4 8
5 28
6 90
7 66
8 82
9 74

However, when both of the DMD2 library and IRremote are combined, theres interference within the IR receiver. It does not print out value as it does when not combined with the DMD2 library.

Here are the codes combined:

#include <DMD2.h>
#include <EEPROM.h>
#include <fonts/MyBigFont.h>
#include <IRremote.h>

#define WIDTH 2
#define HEIGHT 1

int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);

// CAR MP3 (decodedIRData.command)
// #define IR_BUTTON_CH-        69
// #define IR_BUTTON_CH         70
// #define IR_BUTTON_CH+        71
// #define IR_BUTTON_REWIND     68
// #define IR_BUTTON_FORWARD    64
// #define IR_BUTTON_PLAYPAUSE  67
// #define IR_BUTTON_-           7
// #define IR_BUTTON_+          21
// #define IR_BUTTON_EQ          9
// #define IR_BUTTON_0          22
// #define IR_BUTTON_100+       25
// #define IR_BUTTON_200+       13
#define IR_BUTTON_1          12
// #define IR_BUTTON_2          24
// #define IR_BUTTON_3          94
// #define IR_BUTTON_4           8
// #define IR_BUTTON_5          28
// #define IR_BUTTON_6          90
// #define IR_BUTTON_7          66
// #define IR_BUTTON_8          82
// #define IR_BUTTON_9          74

SoftDMD dmd(WIDTH, HEIGHT);

byte Brightness;
byte debounce = 500;

int leftScore = 0;
int rightScore = 0;

char dmdBuff[10];  // define dmdBuff as a character array with length 10

void setup() {
  Brightness = EEPROM.read(0);
  dmd.begin();
  dmd.setBrightness(10);
  dmd.selectFont(MyBigFont);
  dmd.clearScreen();
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
}

void DisplayScore() {
static unsigned long lastDisplayTime = 0;
  if (millis() - lastDisplayTime > 500) {
  sprintf(dmdBuff,"%d",leftScore)  ;
  dmd.drawString( 7, 0, dmdBuff );
  dmd.drawString( 29, 0, "-" );
  sprintf(dmdBuff,"%2d",rightScore);
  dmd.drawString( 37, 0, dmdBuff );
  lastDisplayTime = millis();
  }
}

void loop() {
  DisplayScore();

  if (irrecv.decode()) {
    Serial.println(irrecv.decodedIRData.command);
    irrecv.resume();  // Receive the next value

    switch (irrecv.decodedIRData.command) {

      case IR_BUTTON_1:  // Button 1
        leftScore++;
        DisplayScore();
        break;
      
      // case IR_BUTTON_2:  // Button 2
      //   rightScore++;
      //   DisplayScore();
      //   break;

      // case IR_BUTTON_3:  // Button 3
      //   leftScore--;
      //   DisplayScore();
      //   break;
      
      // case IR_BUTTON_4:  // Button 4
      //   rightScore--;
      //   DisplayScore();
      //   break;

      // case IR_BUTTON_5:  // Button 5
      //   leftScore = 0;
      //   rightScore = 0;
      //   DisplayScore();
      //   break;
    }
  }
}

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advice on) your project.

1 Like

Read GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols

Both libraries are quite timing critical. As DMD2 does a rather lengthy operation in a timer interrupt it interferes heavily with the infrared signal reading of IRremote. I suggest to split the two tasks into separate Arduinos which communicate by a method done mostly in hardware (p.e. UART).

what do you mean by seperating the arduino in hardware method?
is there any other library that i could use?
thankyou for helping :slight_smile:

I wrote something different: separate the task into two Arduinos! So you run DMD2 on one Arduino and IRremote on the other and have an UART (in hardware, so no SoftwareSerial shit) communication between the two.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.