Go Down

Topic: Adafruit Wave shield button press song (Read 912 times) previous topic - next topic

ash901226

Code: [Select]
 
  buttonState = digitalRead(buttonPin);
 
 
 root.rewind();
 play(root);

while(wave.isplaying){
  if(buttonState==HIGH){
 // wave.pause();
  digitalWrite(ledPin, HIGH);  
//   //Serial.println("HIGH");
 }
  else{
     //wave.resume();
     digitalWrite(ledPin, LOW);  
//    // Serial.println("LOW");
   }
 }



actually your have not define a micro....
how about you do this at the top
#define buttonState digitalRead(buttonPin);
this way every time you write buttonState it mean it will read the current state of the button pin

what you did here in perticular is
Code: [Select]
buttonState = digitalRead(buttonPin);
 
 
 root.rewind();
 play(root);

while(wave.isplaying){
  if(buttonState==HIGH){


your only using the state that was read outside the while loop so if b4 the while loop happen the state of the button state is low, then inside the while loop ,that if will never be true.

ash901226

use the program that you use in reply 5 and but change this
Code: [Select]
if(buttonState==HIGH){
to this
Code: [Select]
if(digitalRead(buttonPin)==HIGH){

danieljay


wildbill

You're making life harder for yourself using that example code - it's designed to loop through every wav file on your SD card. There is a simpler example on the ladyada site (where I assume you got your code): http://www.ladyada.net/make/waveshield/libraryhcplay6.html. Try and get the playfile function working in your code instead of play. Then you should finally see your serial prints at least.

Go Up