Music Maker Shield and servos
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- lefthandsh8k_
- Posts: 35
- Joined: Fri Jul 10, 2015 4:23 pm
Re: Music Maker Shield and servos
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!
- adafruit_support_bill
- Posts: 89199
- Joined: Sat Feb 07, 2009 10:11 am
Re: Music Maker Shield and servos
Try replacing your loop() code with this:
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.
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");
}
- lefthandsh8k_
- Posts: 35
- Joined: Fri Jul 10, 2015 4:23 pm
Re: Music Maker Shield and servos
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
Here's what the serial monitor is outputting:
2340Adafruit VS1053 Library Test
VS1053 found
SD OK!
117595 - Started playing
117595 - Done playing music
- adafruit_support_bill
- Posts: 89199
- Joined: Sat Feb 07, 2009 10:11 am
Re: Music Maker Shield and servos
There must be more output than that. And is the music playing?
- lefthandsh8k_
- Posts: 35
- Joined: Fri Jul 10, 2015 4:23 pm
Re: Music Maker Shield and servos
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.
- adafruit_support_bill
- Posts: 89199
- Joined: Sat Feb 07, 2009 10:11 am
Re: Music Maker Shield and servos
So it only prints those 5 lines and stops completely?That is all I'm seeing from the serial monitor.
The servo moves but it never prints " - Music Playing"?The music is playing, and this time the servo is working ,of course after the track plays.
- lefthandsh8k_
- Posts: 35
- Joined: Fri Jul 10, 2015 4:23 pm
Re: Music Maker Shield and servos
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.
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.
- adafruit_support_bill
- Posts: 89199
- Joined: Sat Feb 07, 2009 10:11 am
Re: Music Maker Shield and servos
That seems very strange. Please post the exact code you are currently running.
Please be positive and constructive with your questions and comments.