Die zu verwendende Bibliothek ist JQ6500_Serial von James Sleeman. Sie ist unter folgendem Link zu finden:
https://github.com/sleemanj/JQ6500_SerialHier der in die Gesamt-SW zu integrierende Beispielcode von mir:
/** Full demo of MP3 Controls, after uploading, open your Serial Monitor and enter commands.
*
* Allows you to test all the various controls of the JQ6500 module.
*
* @author James Sleeman,
http://sparks.gogo.co.nz/ * @license MIT License
* @file
*/
#include <Arduino.h>
#include <JQ6500_Serial.h>
#include <SoftwareSerial.h>
// Create the mp3 module object,
// Arduino Pin 8 is connected to TX of the JQ6500
// Arduino Pin 9 is connected to one end of a 1k resistor,
// the other end of the 1k resistor is connected to RX of the JQ6500
// If your Arduino is 3v3 powered, you can omit the 1k series resistor
int pinSoundIn = 8;
int pinSoundOut = 9;
JQ6500_Serial mp3(pinSoundIn,pinSoundOut);
typedef enum {ATHMO1=1,ATHMO2,ATHMO3,START,START2,END,END2,END3,END4,GOAL,GOAL2,FASTBALL,FASTBALL2,MATCHBALL,OVER,TOPOVER,TOPOVER2,GASP,FAME,DEMO,DEMOLONG,SOUNDCOUNT} sound_type;
//SOUNDCOUNT ist counter bzw. Endwert
void runSound(sound_type snd, int vol)
{
mp3.pause();
if (vol>30)
{
vol = 30;
}
mp3.setVolume(vol); // set volume (1-30)
mp3.playFileByIndexNumber(snd); //play file by given index, if it exists
}
void initSound(int pinSoundIn,int pinSoundOut)
{
//JQ6500_Serial mp3(pinSoundIn,pinSoundOut);
mp3.begin(9600); //start 9600Khz
mp3.reset(); //reset chip
mp3.setLoopMode(MP3_LOOP_ONE_STOP); //no looping
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
initSound(pinSoundIn,pinSoundOut);
pinMode(buttonPin, INPUT_PULLUP);
Serial.println("setup completed");
}
void loop() //Beispielaufruf der Tonausgabe
{
runSound(ATHMO1,15); //ATHMO1 hat den integer-wert 1
delay (60000); //warte 60 Sekunden vorAbspielen des nächsten Tons
}