input pullup , wired input and output pins

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.

debounce button or something else?

help. tnx.

Please post the full code running on the master and slave

Why is the code on the master uneditable ?

on master arduino software is mardec with programamble pins, i dont have full code.

also, here is combination (see attach.) of output states on pins, for leds etc, coils, servo, etc. on master arduino

code for slave

***************************************************
  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

}

}

on master arduino software is mardec

What is mardec ?

PrinzEugen:
then mp3 on slave arduino sample wouldn't start until output and pin2 are connected for a brief moment (pushbutton example),

if (digitalRead(2)==LOW) myDFPlayer.play(1); // play mp3 sample

looks like player is only enabled to play as long as the input is LOW. it sounds like you want it to play whenever the input is momentarily low.

you could set a "state" whenever the input goes LOW which could be reset after the playing is complete

yes, any clue how to do that ?

how do you know when the player is done playing?

  1. 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).

  2. 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

so this is for a model railroad

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

any option will be welcome.

servo rotates -output pin goes low

how does servo rotating affect output pin?

myDFPlayer.play(1);

does play() return when audio is complete. if you, continue to call play() while input LOW

here is link for software manual , page 23 http://www.globalvisuals.nl/downloads/mardecUK.pdf

in table , servo option for output pin

don't ask me about code, which i know very little.