Issue i have is when master arduino or slave sends low output to pin e.g 2, then mp3 on slave arduino sample wouldn't start until output and pin2 are connected for a brief moment (pushbutton example),
part of code
pinMode(2,INPUT_PULLUP);
void loop(){
if (digitalRead(2)==LOW) myDFPlayer.play(1); // play mp3 sample
since i will not use buttons and switches, therefore output and input are connected directly, another sample would be played only if low signal is sent again. i hope you understand what i meant. here's picture.
***************************************************
DFPlayer - A Mini MP3 Player For Arduino
<https://www.dfrobot.com/index.php?route=product/product&product_id=1121>
***************************************************
This example shows the basic function of library for DFPlayer.
Created 2016-12-07
By [Angelo qiao](Angelo.qiao@dfrobot.com)
GNU Lesser General Public License.
See <http://www.gnu.org/licenses/> for details.
All above must be included in any redistribution
****************************************************/
/***********Notice and Trouble shooting***************
1.Connection and Diagram can be found here
<https://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299#Connection_Diagram>
2.This code is tested on Arduino Uno, Leonardo, Mega boards.
****************************************************/
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#define pin 2 // connect to master digital output "pin"
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);
void setup()
{
mySoftwareSerial.begin(9600);
Serial.begin(115200);
pinMode(2,INPUT_PULLUP);
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
if (!myDFPlayer.begin(mySoftwareSerial)) { //Use softwareSerial to communicate with mp3.
Serial.println(F("Unable to begin:"));
Serial.println(F("1.Please recheck the connection!"));
Serial.println(F("2.Please insert the SD card!"));
while (true);
}
Serial.println(F("DFPlayer Mini online."));
myDFPlayer.volume(15); //Set volume value. From 0 to 30
}
void loop(){
if (digitalRead(2)==LOW) myDFPlayer.play(1); // turn on
}
}
when the signal is set low on output master pin, example: level crossing barrier lifts up and triggers momentarily low signal to play 5 second long mp3 sample (bell ringing).
in meantime set input_pullup pin to float, and get ready for next high input when barrier needs to close...
low signal from output - level crossing barrier lift
high signal from output- level crossing barrier close
PrinzEugen:
2. in meantime set input_pullup pin to float, and get ready for next high input when barrier needs to close...
why are you reconfiguring the pin w/o a PULLUP? wouldn't the input get pulled high with the detector goes inactive?
you didn't answer my question about how do you know when the player is done? and based on what you just said, it sounds like it may need to be replayed
yes sample need to be replayed, sound starts every time input changes from low to high or opposite.
one of the option is output port which changes state of pin depending on servo position (in this case level crossing barrier), maybe this is easier solution.
servo rotates -output pin goes low = sample is played one time until servo reaches desired position
servo stopped -output pin goes high = sample stops