when the mp3 start to work I cant get any serial output from the 433 rf
and I cant control on Arduino with rf commends like its block the incoming data
here is the code:
#include <RCSwitch.h>
// Include required libraries:
#include <SoftwareSerial.h>
// Define the RX and TX pins to establish UART communication with the MP3 Player Module.
#define MP3_RX 5 // to TX
#define MP3_TX 4 // to RX
// Select storage device to TF card
static int8_t select_SD_card[] = {0x7e, 0x03, 0X35, 0x01, 0xef}; // 7E 03 35 01 EF
// Play with index: /01/001xxx.mp3
static int8_t play_first_song[] = {0x7e, 0x04, 0x41, 0x00, 0x01, 0xef}; // 7E 04 41 00 01 EF
// Play with index: /01/002xxx.mp3
static int8_t play_second_song[] = {0x7e, 0x04, 0x41, 0x00, 0x02, 0xef}; // 7E 04 41 00 02 EF
// Play the song.
static int8_t play[] = {0x7e, 0x02, 0x01, 0xef}; // 7E 02 01 EF
// Pause the song.
static int8_t pause[] = {0x7e, 0x02, 0x02, 0xef}; // 7E 02 02 EF
static int8_t sleep2[] = {0x7e, 0x03, 0x35, 0x03, 0xef};
static int8_t wake[] = {0x7E, 0x03, 0x35, 0x02, 0xef};
SoftwareSerial MP3(MP3_RX, MP3_TX);
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(19200);
MP3.begin(9600);
// Select the SD Card.
send_command_to_MP3_player(select_SD_card, 5);
mySwitch.enableReceive(1); // Receiver on interrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
if (mySwitch.getReceivedValue() == 1244)
{
send_command_to_MP3_player(play, 4);
}
if (mySwitch.getReceivedValue() == 1245)
{
send_command_to_MP3_player(pause, 4);
}
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());
mySwitch.resetAvailable();
}
}
void send_command_to_MP3_player(int8_t command[], int len){
for(int i=0;i<len;i++){ MP3.write(command[i]);}
delay(250);
}