Music Maker Shield and servos

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
lefthandsh8k_
 
Posts: 35
Joined: Fri Jul 10, 2015 4:23 pm

Re: Music Maker Shield and servos

Post by lefthandsh8k_ »

Actually, now the servo isn't moving at all(it was as of my last reply, but now seems to lock up).I swapped it out to see if maybe it was just bad, but that doesn't appear to be the case. I haven't changed any of the code either, so I'm pretty confused!

User avatar
adafruit_support_bill
 
Posts: 89199
Joined: Sat Feb 07, 2009 10:11 am

Re: Music Maker Shield and servos

Post by adafruit_support_bill »

Try replacing your loop() code with this:

Code: Select all

void loop() 
{  
    // Start playing a file, then we can do stuff while waiting for it to finish
    if (! musicPlayer.startPlayingFile("track001.wav")) 
    {
        Serial.println("Could not open file track001.wav");
    }
    Serial.print(millis());
    Serial.println(F(" - Started playing"));

    while (musicPlayer.playingMusic) 
    {
        // file is now playing in the 'background' so now's a good time
        // to do something else like handling LEDs or buttons :)
        Serial.print(millis());
        Serial.println(" - Music Playing");
        for (pos = 0; pos <= 180; pos += 1) 
        { // goes from 0 degrees to 180 degrees
            // in steps of 1 degree
            myservo.write(pos);              // tell servo to go to position in variable 'pos'
            delay(15);                       // waits 15 ms for the servo to reach the position
        }
        for (pos = 180; pos >= 0; pos -= 1) 
        { // goes from 180 degrees to 0 degrees
            myservo.write(pos);              // tell servo to go to position in variable 'pos'
            delay(15);                       // waits 15 ms for the servo to reach the position
        }
    }
    Serial.print(millis());
    Serial.println(" - Done playing music");
}
I've removed the dead code to simplify things and added some timing output that might shed some light on what is going on there.

User avatar
lefthandsh8k_
 
Posts: 35
Joined: Fri Jul 10, 2015 4:23 pm

Re: Music Maker Shield and servos

Post by lefthandsh8k_ »

Sorry it took so long to respond.
Here's what the serial monitor is outputting:

2340Adafruit VS1053 Library Test
VS1053 found
SD OK!
117595 - Started playing
117595 - Done playing music

User avatar
adafruit_support_bill
 
Posts: 89199
Joined: Sat Feb 07, 2009 10:11 am

Re: Music Maker Shield and servos

Post by adafruit_support_bill »

There must be more output than that. And is the music playing?

User avatar
lefthandsh8k_
 
Posts: 35
Joined: Fri Jul 10, 2015 4:23 pm

Re: Music Maker Shield and servos

Post by lefthandsh8k_ »

That is all I'm seeing from the serial monitor. The music is playing, and this time the servo is working ,of course after the track plays.

User avatar
adafruit_support_bill
 
Posts: 89199
Joined: Sat Feb 07, 2009 10:11 am

Re: Music Maker Shield and servos

Post by adafruit_support_bill »

That is all I'm seeing from the serial monitor.
So it only prints those 5 lines and stops completely?
The music is playing, and this time the servo is working ,of course after the track plays.
The servo moves but it never prints " - Music Playing"?

User avatar
lefthandsh8k_
 
Posts: 35
Joined: Fri Jul 10, 2015 4:23 pm

Re: Music Maker Shield and servos

Post by lefthandsh8k_ »

Ok so I double checked and ran the code again, and now it's doing something completely different. Here's the current serial monitor output as it's running right now:
Adafruit VS1053 Library Test
VS1053 found
SD OK!
117710 - Started playing
234213 - Music Playing
356198 - Music Playing
478168 - Music Playing
600118 - Music Playing
722070 - Music Playing
844023 - Music Playing

The servo is rotating after, but now I never see" done playing music"! I haven't made any changes since I last posted. This is bizarre. I'm very confused about the inconsistent behaviour.

User avatar
adafruit_support_bill
 
Posts: 89199
Joined: Sat Feb 07, 2009 10:11 am

Re: Music Maker Shield and servos

Post by adafruit_support_bill »

That seems very strange. Please post the exact code you are currently running.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”