#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial mySoftwareSerial(10,11);
SoftwareSerial mySoftwareSerial2(6,7);
SoftwareSerial mySoftwareSerial3(4,5);
const int volumePin = A5; //Regler
int volumeState = 0; //Regler
DFRobotDFPlayerMini myDFPlayer;
DFRobotDFPlayerMini myDFPlayer2;
DFRobotDFPlayerMini myDFPlayer3;
void setup() {
Serial.begin(9600);
mySoftwareSerial.begin(9600);
myDFPlayer.begin(mySoftwareSerial);
if (!myDFPlayer.begin(mySoftwareSerial)) {
while(true){
delay(0); }
}
mySoftwareSerial2.begin(9600);
myDFPlayer2.begin(mySoftwareSerial2);
if (!myDFPlayer2.begin(mySoftwareSerial2)) {
while(true){
delay(0); }
}
mySoftwareSerial3.begin(9600);
myDFPlayer3.begin(mySoftwareSerial3);
if (!myDFPlayer3.begin(mySoftwareSerial3)) {
while(true){
delay(0); }
}
myDFPlayer.reset(); //Reset the module
myDFPlayer2.reset(); //Reset the module
myDFPlayer3.reset(); //Reset the module
//myDFPlayer.randomAll();
//myDFPlayer.enableLoopAll();
//myDFPlayer.loopFolder(1);
myDFPlayer.volume(5); // Lautstärke 5 (30)
myDFPlayer2.volume(5); // Lautstärke 5 (30)
myDFPlayer3.volume(5); // Lautstärke 5 (30)
// Set different EQ
// myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
// myDFPlayer.EQ(DFPLAYER_EQ_POP);
// myDFPlayer.EQ(DFPLAYER_EQ_ROCK);
// myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
// myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
// myDFPlayer.EQ(DFPLAYER_EQ_BASS)
//myDFPlayer.play();
//myDFPlayer2.play(3);
myDFPlayer.loopFolder(1);
myDFPlayer2.loopFolder(1);
myDFPlayer3.loopFolder(1);
//myDFPlayer2.randomAll();
}
void loop() {
int state;
state = analogRead(volumePin);
state = map(state, 0, 1023, 0, 30);
if (state < volumeState - 1 || state > volumeState + 1)
{
volumeState = state;
}
myDFPlayer.volume(volumeState); //Set volume value (0~30).
myDFPlayer2.volume(volumeState); //Set volume value (0~30).
myDFPlayer3.volume(volumeState); //Set volume value (0~30).
} |