Go Down

Topic: wtv020SD-16P Play file 1, when song is over play file 14(no delays) (Read 45 times) previous topic - next topic

Thomas499

I am having a hard time getting my home made mp3 player to work correctly. Is it possible to have one song play, then another (that isn't the number that was just played+1) to automatically play when the song is finished? I want to do this without having to manually put in how long each song last using the delay function. I've tried using the busy pin to figure out if a song is playing, but i'm having a hard time figuring it out.

Here is my code, can anyone lead me in the right direction?

Code: [Select]
/*
 Example: Control a WTV020-SD-16P module to play voices from an Arduino board.
 Created by Diego J. Arevalo, August 6th, 2012.
 Released into the public domain.
 */

#include <Wtv020sd16p.h>

int resetPin = 4;  // The pin number of the reset pin.
int clockPin = 5;  // The pin number of the clock pin.
int dataPin = 6;  // The pin number of the data pin.
int busyPin = 7;  // The pin number of the busy pin.
boolean onlyOnce=HIGH;
/*
Create an instance of the Wtv020sd16p class.
 1st parameter: Reset pin number.
 2nd parameter: Clock pin number.
 3rd parameter: Data pin number.
 4th parameter: Busy pin number.
 */
Wtv020sd16p wtv020sd16p(resetPin,clockPin,dataPin,busyPin);

void setup() {
  Serial.begin(9600);
  //Initializes the module.
  wtv020sd16p.reset();
}

void loop() { while (digitalRead(busyPin==LOW))
{delay(50);
if (digitalRead(busyPin)==LOW){Serial.print("reset pin is ");
    Serial.println(digitalRead(resetPin));
    Serial.print("clockPin is ");
    Serial.println(digitalRead(clockPin));
    Serial.print("dataPin is ");
    Serial.println(digitalRead(dataPin));
    Serial.print("busyPin is ");
    Serial.println(digitalRead(busyPin));
    //if (onlyOnce==HIGH)
    //{
      yapizza();
      //}

    }
}
}
void yapizza(){
  //Plays synchronously an audio file. Busy pin is used for this method.
  wtv020sd16p.playVoice(1);
  //Plays asynchronously an audio file.
  wtv020sd16p.asyncPlayVoice(5);
  //Plays audio file number 1 during 2 seconds.
  //Stops current audio file playing.
  wtv020sd16p.stopVoice();
  wtv020sd16p.playVoice(14);
  wtv020sd16p.asyncPlayVoice(8);
  //Plays synchronously an audio file. Busy pin is used for this method. 
  //Mutes audio file number 2 during 2 seconds.   
  //Stops current audio file playing.
  wtv020sd16p.stopVoice();
}



Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy