Arduino can play with the code below(changing to next or previous audio).
But it seems it can't read the data inside ().
ex. When I change the number in the volume(), nothing happened.
#include <DFRobotDFPlayerMini.h>
#include <SoftwareSerial.h>
#include "Arduino.h"
SoftwareSerial mySoftwareSerial(11, 10); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
//void printDetail(uint8_t type, int value);
void setup()
{
//----------------------------------------mp3
mySoftwareSerial.begin(9600);
Serial.begin(115200);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("sensing.. (take 3~5 seconds)"));
if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("Error!"));
while (true) {
delay(0); // Code to compatible with ESP8266 watch dog.
}
}
Serial.println(F("DFPlayer Mini working."));
myDFPlayer.volume(10); //Set volume value. From 0 to 30
//----------------------------------------gesture
while (!Serial);
if (!APDS.begin()) {
Serial.println("Error!");
Serial.println("Detecting gestures ...");
}
}
void loop()
{
if (APDS.gestureAvailable()) {
int gesture = APDS.readGesture();
if (gesture == GESTURE_LEFT) {
Serial.println("LEFT ");
myDFPlayer.next();
delay(5000);
}
if (gesture == GESTURE_RIGHT) {
Serial.println("RIGHT ");
myDFPlayer.previous();
delay(5000);
}
}
}
Also, I want to assign which audio to be played.
It can't read and work. I think it's the same problem: can't read the data in the ().
if (gesture == GESTURE_LEFT) {
Serial.println("LEFT ");
myDFPlayer.play(1);
delay(5000);
}
if (gesture == GESTURE_RIGHT) {
Serial.println("RIGHT ");
myDFPlayer.play(2);
delay(5000);
}
I'm not pretty sure if that's the real problem...hope to solve this soon.
Thanks for everyone's help...