[SOLVED] SFEMP3Shield + IRremote

Hi all !

Sorry for my english (I’m french).

I would like create an MP3 player controlled with an IR remote control.
But I am having some problems with implementation.
So I need your help.

Materials used :

Arduino libraries used :

First, I have tested le MP3 Shield with the exemple FilePlayer provided with the library SFEMP3Shield.
All is ok.

So, I do a sketch to receive the remote signal (Attached file : Telecommande_receiver.ino).
All is ok too.
Then, I was able to get the key codes that interest me and make a new sketch (Attached file : Skeleton.ino) which will serve as my base to control the MP3 shield.

I proceeded to mix it with the example sketch FilePlayer (Attached file : PlayerMP3.ino).
That is where the problems appeared.
The first time I use the remote, it works.
As the song is not complete, the code of the key pressed recovered is wrong.
When the song is over, the IR receiver returns the correct code.
And so on.

After doing some research on the net, I deduced it was conflict between the external interrupts used by the two libraries SFEMP3Shield and IRremote.

The Arduino UNO can handle two external interrupts.
So I first tried to change the libraries that they use a different interrupt.
Test 1 :
I try to change IrremoteInt.h line 66 to 67 :

//#define IR_USE_TIMER1 // tx = pin 9
#define IR_USE_TIMER2 // tx = pin 3

by

#define IR_USE_TIMER1 // tx = pin 9
//#define IR_USE_TIMER2 // tx = pin 3

Nothing change : always an wrong code while a song is playing.

Test 2 :
Come back to the original file IrremoteInt.h and I try to change SFEMP3ShieldConfig.h line 187 :

#define MP3_DREQINT          0

by

#define MP3_DREQINT          1

In the case, the remote is good but no music.

So I tested different things on SFEMP3Shield library
Test 3 :
Come back to the original file SFEMP3ShieldConfig.h and I changed the line 220 :

#define USE_MP3_REFILL_MEANS USE_MP3_INTx

by

#define USE_MP3_REFILL_MEANS USE_MP3_Polled

And I also added the following line at the beginning of my loop ():

MP3player.available ();

In this case, it works pretty well: the remote control is used even when a song is playing.
By cons, some SFEMP3Shield library functions do not work as :

  • pauseMusic
  • resumeMusic

And when I use end () then nothing works.
Same when I tested with the example FilePlayer

Test 4 :
I left the original files and I re-edited the file SFEMP3ShieldConfig.h changing the line 220 :

#define USE_MP3_REFILL_MEANS USE_MP3_INTx

by

#define USE_MP3_REFILL_MEANS USE_MP3_Timer1

I installed the library TimerOne and have included it in my code.
I also putted the following line at the beginning of my loop ():

MP3player.available ();

Then I return to the basic problem: the remote control is no longer usable as a song is playing.

Test 5 :
I left the original files and I re-edited the file SFEMP3ShieldConfig.h changing the line 220 :

#define USE_MP3_REFILL_MEANS USE_MP3_INTx

by

#define USE_MP3_REFILL_MEANS USE_MP3_SimpleTimer

I installed the library SimpleTimer and have included it in my code.
Then I return to the test 2 : remote is ok but no music.

I do not know what else to do!
I need help.
Thank you in advance.

PlayerMP3.ino (4.52 KB)

Skeleton.ino (1.76 KB)

Telecommande_receiver.ino (295 Bytes)

You should realize that the Atmega timers are not symmetrical. They have somewhat different features and involve intricate coding.

Thanks joe mcd for your help but I don’t understand that you explain.

Atmega timers are not symmetrical

Can you tell me more ?

I don’t use timers and interrupts in my sketch.
They are only used in libraries SFEMP3Shield and IRremote.
I think these librairies are good.
I probably set something wrong.

I solved my problem. You can see that here (in French)