/* 28//09/2021 * UARTSerialV2 * * Creating some useful functions * Serial MP3 Player A | Arduino UNO R3 RX | 3 TX | 4 VCC | 5V GND | GND */ #include "SoftwareSerial.h" #define ARDUINO_RX 4//should connect to TX of the Serial MP3 Player module #define ARDUINO_TX 3//connect to RX of the module SoftwareSerial myMP3(ARDUINO_RX, ARDUINO_TX); byte sendBuffer[6]; //buffer that will be used to store commands before sending //Manual says the code for this is 7E 03 35 01 EF so load into buffer array void selectTFCard(){ sendBuffer[0] = 0x7E; sendBuffer[1] = 0x03; sendBuffer[2] = 0x35; sendBuffer[3] = 0x01; sendBuffer[4] = 0xEF; sendUARTCommand(); } void playSound(byte songNumber){ sendBuffer[0] = 0x7E; sendBuffer[1] = 0x04; sendBuffer[2] = 0x41; sendBuffer[3] = 0x00; sendBuffer[4] = songNumber; sendBuffer[5] = 0xEF; sendUARTCommand(); } //play a sound at a set volume, only seems to apply to root directory files void playSoundAtVolume(byte volume,byte songNumber){ sendBuffer[0] = 0x7E; sendBuffer[1] = 0x04; sendBuffer[2] = 0x31; sendBuffer[3] = volume; sendBuffer[4] = songNumber; sendBuffer[5] = 0xEF; sendUARTCommand(); } // //set the playback volume 7E 03 31 0F EF = set volume to 0x0F = 15 void setplayVolume(byte volume){ sendBuffer[0] = 0x7E; sendBuffer[1] = 0x03; sendBuffer[2] = 0x31; sendBuffer[3] = volume; sendBuffer[4] = 0xEF; sendUARTCommand(); } //stop the current track playing void stopSound(){ sendBuffer[0] = 0x7E; sendBuffer[1] = 0x02; sendBuffer[2] = 0x0E; sendBuffer[3] = 0xEF; sendUARTCommand(); } void sendUARTCommand(){ int q; for(q=0;q