I have some problem.
I want to use “DFPlayer mini” through the value from MPU6050 gyro sensor.
but MPU6050 passing too many values at a time. (1111111111111122222222222222223333333…)
and the music from “DFPlayer mini” is under Buffering.
the music is very short (3~4 sec.)
and they communicate each other with xbee.
.
.
.
.
if (xbee.available()) {
char data = xbee.read();
if (data == ‘1’) {
Serial.print(1);
xbee.print(‘7’);
}else if (data == ‘2’) {
Serial.print(2);
xbee.print(‘8’);
} else if (data == ‘5’) {
Serial.print(5);
xbee.print(‘9’);
}
}
.
.
.
.
.
- MPU6050 's side
#include <SoftwareSerial.h>
SoftwareSerial xbee(2, 3);
#include <DFPlayer_Mini_Mp3.h>
SoftwareSerial mySerial(10, 11);
#include<Wire.h>
int LeftButton1 = 4;
int LeftButton2 = 5;
int char1 = 0;
int char2 = 0;
int char3 = 0;
void setup() {
Serial.begin(9600);
mySerial.begin (9600);
xbee.begin(9600);
mp3_set_serial (mySerial);
delay(1);
mp3_set_volume (30);
pinMode(LeftButton1, INPUT_PULLUP);
pinMode(LeftButton2, INPUT_PULLUP);
}
void loop() {
mp3_play(1);
delay(3000);
//int Button1 = digitalRead(5);
//if (digitalRead(LeftButton1) == HIGH) {
//Serial.print(“3”);
////xbee.print(‘3’);
//}
if (digitalRead(LeftButton1) == LOW) {
xbee.print(‘1’);
}
if (digitalRead(LeftButton2) == HIGH) {
//Serial.print(“4”);
//xbee.print(‘4’);
}
if (digitalRead(LeftButton2) == LOW) {
xbee.print(‘2’);
}
if ((digitalRead(LeftButton1) == HIGH) && (digitalRead(LeftButton2) == HIGH)) {
xbee.print(‘5’);
}
.
.
.
.
- DFPlayer mini 's side
if (xbee.available()) {
char data = xbee.read();
if (data == ‘7’) {
Serial.print(“7”);
delay(2000);
}
if (data == ‘8’) {
Serial.print(“8”);
mp3_play(2);
delay(2000);
}
if (data == ‘9’) {
Serial.print(“9”);
mp3_play(3);
delay(2000);
}
delay(100);
.
.
.
.