DMD with IRREMOTE library not work good

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
salwan
Posts: 1
Joined: Thu Nov 05, 2015 6:31 pm

DMD with IRREMOTE library not work good

Post by salwan » Thu Nov 05, 2015 6:39 pm

hello My friends ;

I'm Salwan new user here , Please i want to use IR remote control with DMD , but its not work because the timer1 interrupt , i want to design money exchange board using dmd and arduino uno and set exchange rate by infrared remote control >

Please i'm looking to your help and reply quickly .

Thanks

User avatar
stryker
Posts: 268
Joined: Sat Jan 14, 2012 2:44 pm

Re: DMD with IRREMOTE library not work good

Post by stryker » Thu Nov 05, 2015 10:07 pm

Hi Salwan

If you need to stick with iR for your remote, and the interrupt issue can't be avoided, you may be best splitting the two tasks and having one microcontroller dedicated to displaying the messages and the other receiving the iR and sending the display the character string to put on the DMD.

Geoff

Brissieboy
Posts: 131
Joined: Fri Sep 20, 2013 7:25 am

Re: DMD with IRREMOTE library not work good

Post by Brissieboy » Fri Nov 06, 2015 2:11 am

Salwan,
I am successfully using both the DMD library and the IR library in a project. DMD uses timer1 and the IR library uses timer2.

statbat
Posts: 44
Joined: Tue Dec 22, 2015 10:53 am

Re: DMD with IRREMOTE library not work good

Post by statbat » Mon May 23, 2016 4:03 pm

Brissieboy wrote:Salwan,
I am successfully using both the DMD library and the IR library in a project. DMD uses timer1 and the IR library uses timer2.
I am sorry to write in the old post, but can you tell me how did you change the timer.
I am trying to achieve same. Control DMD and IR remote and am facing same issues.

I have UNO and I want to use DMD and IR remote together.
They both work fine separate.

Brissieboy
Posts: 131
Joined: Fri Sep 20, 2013 7:25 am

Re: DMD with IRREMOTE library not work good

Post by Brissieboy » Thu May 26, 2016 11:13 am

statbat,
I used the library available herehere.
The library uses Timer2 by default, but you can change the timer in the file 'IRremoteInt.h' in any case.
There is plenty of documentation on how to use the library.

statbat
Posts: 44
Joined: Tue Dec 22, 2015 10:53 am

Re: DMD with IRREMOTE library not work good

Post by statbat » Sat May 28, 2016 2:43 am

Brissieboy wrote:statbat,
I used the library available here here.
The library uses Timer2 by default, but you can change the timer in the file 'IRremoteInt.h' in any case.
There is plenty of documentation on how to use the library.
First of all, thanks a lot for your reply.

I am using same library.
I even made sure that it is using Timer2 in the file RemoteInt.h
But still I cant make it to work

Code: Select all

// Arduino Mega
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
	//#define IR_USE_TIMER1   // tx = pin 11
	#define IR_USE_TIMER2     // tx = pin 9
	//#define IR_USE_TIMER3   // tx = pin 5
	//#define IR_USE_TIMER4   // tx = pin 6
	//#define IR_USE_TIMER5   // tx = pin 46

// Teensy 1.0
#elif defined(__AVR_AT90USB162__)
	#define IR_USE_TIMER1     // tx = pin 17

// Teensy 2.0
#elif defined(__AVR_ATmega32U4__)
	//#define IR_USE_TIMER1   // tx = pin 14
	//#define IR_USE_TIMER3   // tx = pin 9
	#define IR_USE_TIMER4_HS  // tx = pin 10

// Teensy 3.0 / Teensy 3.1
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
	#define IR_USE_TIMER_CMT  // tx = pin 5

// Teensy-LC
#elif defined(__MKL26Z64__)
  #define IR_USE_TIMER_TPM1 // tx = pin 16

// Teensy++ 1.0 & 2.0
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
	//#define IR_USE_TIMER1   // tx = pin 25
	#define IR_USE_TIMER2     // tx = pin 1
	//#define IR_USE_TIMER3   // tx = pin 16

// Sanguino
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
	//#define IR_USE_TIMER1   // tx = pin 13
	#define IR_USE_TIMER2     // tx = pin 14

// Atmega8
#elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__)
	#define IR_USE_TIMER1     // tx = pin 9

// ATtiny84
#elif defined(__AVR_ATtiny84__)
  #define IR_USE_TIMER1     // tx = pin 6

//ATtiny85
#elif defined(__AVR_ATtiny85__)
  #define IR_USE_TIMER_TINY0   // tx = pin 1

// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
#else
	//#define IR_USE_TIMER1   // tx = pin 9
	#define IR_USE_TIMER2     // tx = pin 3

#endif
My DMD is on the default pins from 6 to onwards.
My IRRemote is on the pin 3.

But dont work. The code works fine if I use 2 separate arduinos. But not on one :?

Brissieboy
Posts: 131
Joined: Fri Sep 20, 2013 7:25 am

Re: DMD with IRREMOTE library not work good

Post by Brissieboy » Sat May 28, 2016 3:53 am

statbat,
Not sure where to start here as I don't know you're doing in your sketch, and you haven't made it clear just what does work and what does not work.
Can you receive anything on the IR? Have you tried any of the sample sketches successfully?
Does the DMD function as expected?
And make sure that you are powering from a decent external 5V power supply and NOT from the USB port. The USB port will NOT power a DMD successfully.

statbat
Posts: 44
Joined: Tue Dec 22, 2015 10:53 am

Re: DMD with IRREMOTE library not work good

Post by statbat » Fri Jun 03, 2016 10:53 am

Brissieboy wrote: statbat,
Not sure where to start here as I don't know you're doing in your sketch, and you haven't made it clear just what does work and what does not work.
Can you receive anything on the IR? Have you tried any of the sample sketches successfully?
Does the DMD function as expected?
And make sure that you are powering from a decent external 5V power supply and NOT from the USB port. The USB port will NOT power a DMD successfully.
I didnt get a chance to work on it. I will try more and update you with more details.
Thanks

statbat
Posts: 44
Joined: Tue Dec 22, 2015 10:53 am

Re: DMD with IRREMOTE library not work good

Post by statbat » Wed Jun 15, 2016 6:14 am

statbat wrote: I didnt get a chance to work on it. I will try more and update you with more details.
Thanks
Here is my code. It does not work. I am trying with Arduino Mega.

Code: Select all

////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  DMD LED Matrix
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <IRremote.h>

#include <SPI.h>
#include <DMD2.h>
#include <fonts/Arial_Black_16.h>
#include <fonts/SystemFont5x7.h>

// Number of displays
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN   5

SoftDMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);	// DMD controls the entire display
DMD_TextBox box(dmd, 0, 40, 31, 56);				  // "box" provides a text box to automatically write to/scroll the display

unsigned int loopCount = 0;

////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BLACK KEYES REMOTE
#define KEY_OK    "FF02FD"
#define KEY_UP    "FF629D"
#define KEY_DOWN  "FFA857"
#define KEY_LEFT  "FF22DD"
#define KEY_RIGHT "FFC23D"
#define KEY_HASH  "FF52AD"
#define KEY_STAR  "FF42BD"

#define KEY_NUMBER_0  "FF4AB5"
#define KEY_NUMBER_1  "FF6897"
#define KEY_NUMBER_2  "FF9867"
#define KEY_NUMBER_3  "FFB04F"
#define KEY_NUMBER_4  "FF30CF"
#define KEY_NUMBER_5  "FF18E7"
#define KEY_NUMBER_6  "FF7A85"
#define KEY_NUMBER_7  "FF10EF"
#define KEY_NUMBER_8  "FF38C7"
#define KEY_NUMBER_9  "FF5AA5"

#define KEY_REPEAT    "FFFFFFFF"

byte IR_RECV_POS = 0;
byte IR_REPEAT_COUNT = 0;

int RECV_PIN	= 46;
 
IRrecv irrecv(RECV_PIN);
decode_results results;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// the setup routine runs once when you press reset:
void setup()
{
    Serial.begin(9600);								  // Serial connection to Monitor  
    Serial.println(F("Program started"));
   
    irrecv.enableIRIn(); // Start the receiver
        
    // DMD Brightness
    dmd.setBrightness(120);
    dmd.begin();
  
    // Print the Hi
    dmd.clearScreen();
    dmd.selectFont(Arial_Black_16);
    dmd.drawString(0, 16, "HI");
  
} // setup function ends here //

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// the loop routine runs over and over again forever:
void loop()
{  
    //*********************************************************************************************
    //
    //  RECEIVE DATA FROM INFRARED
    //
    //*********************************************************************************************
	  if (irrecv.decode(&results)) 
	  {
		long int decCode      = results.value;
		String hexCode        = String(decCode, HEX);

		hexCode.toUpperCase();
		String decodedSignal  = decodeSignal(hexCode);

		Serial.print("dec: ");
		Serial.print(decCode);
		Serial.print("| HEX: ");
		Serial.print(hexCode);
		Serial.print("|");
		Serial.print(decodedSignal);
		Serial.println();

		// Serial.println(, HEX);
		irrecv.resume(); // Receive the next value

		Serial.println();      
	  }
}

String decodeSignal(String hex)
{
		if (hex == KEY_OK) return "OK";
		if (hex == KEY_UP) return "Up";
		if (hex == KEY_DOWN) return "Down";
		if (hex == KEY_LEFT) return "Left";
		if (hex == KEY_RIGHT) return "Right";
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The hexa code are all over the place. They are just random numbers.
If I remove all DMD reference they become fine.

I have no clue
It is my test app. I did so much different options with no luck.

I dont want to use two ardiunos.

Thanks

statbat
Posts: 44
Joined: Tue Dec 22, 2015 10:53 am

Re: DMD with IRREMOTE library not work good

Post by statbat » Wed Jun 15, 2016 6:22 am

And my IRRemoteInt.h looks like this

Code: Select all

//------------------------------------------------------------------------------
// Define which timer to use
//
// Uncomment the timer you wish to use on your board.
// If you are using another library which uses timer2, you have options to
//   switch IRremote to use a different timer.
//
#define IR_USE_TIMER5

// Arduino Mega
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
	//#define IR_USE_TIMER1   // tx = pin 11
	//#define IR_USE_TIMER2     // tx = pin 9
	//#define IR_USE_TIMER3   // tx = pin 5
	//#define IR_USE_TIMER4   // tx = pin 6
	#define IR_USE_TIMER5   // tx = pin 46

// Teensy 1.0
#elif defined(__AVR_AT90USB162__)
	#define IR_USE_TIMER1     // tx = pin 17

// Teensy 2.0
#elif defined(__AVR_ATmega32U4__)
	//#define IR_USE_TIMER1   // tx = pin 14
	//#define IR_USE_TIMER3   // tx = pin 9
	#define IR_USE_TIMER4_HS  // tx = pin 10

// Teensy 3.0 / Teensy 3.1
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
	#define IR_USE_TIMER_CMT  // tx = pin 5

// Teensy-LC
#elif defined(__MKL26Z64__)
  #define IR_USE_TIMER_TPM1 // tx = pin 16

// Teensy++ 1.0 & 2.0
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
	//#define IR_USE_TIMER1   // tx = pin 25
	#define IR_USE_TIMER2     // tx = pin 1
	//#define IR_USE_TIMER3   // tx = pin 16

// Sanguino
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
	//#define IR_USE_TIMER1   // tx = pin 13
	#define IR_USE_TIMER2     // tx = pin 14

// Atmega8
#elif defined(__AVR_ATmega8P__) || defined(__AVR_ATmega8__)
	#define IR_USE_TIMER1     // tx = pin 9

// ATtiny84
#elif defined(__AVR_ATtiny84__)
  #define IR_USE_TIMER1     // tx = pin 6

//ATtiny85
#elif defined(__AVR_ATtiny85__)
  #define IR_USE_TIMER_TINY0   // tx = pin 1

// Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, Nano, etc
#else
	//#define IR_USE_TIMER1   // tx = pin 9
	#define IR_USE_TIMER2     // tx = pin 3

#endif

But still no luck.
I dont know how you manage to run DMD and IRRemote on the same arduino.

Post Reply