Servos and music synchronisation with Seed Music Shield Seed v2.0

Hello all,
I am working on a project that need to operate multiple servos in a specific sequence, and play specfic music tracks in accordance to this sequence.

Exemple:
servo1 from 0 to 90
play music track 1

servo 2 from 45 to 45
play music track 2

I am currently working with Arduino Mega, analog servos (with separate power supply) and Seeed Music Shield v2.0.
I have tried many options, but there is no way I can play specific music tracks in sequence with the servos.
Seedstudio wiki page does not mention servo usage.
http://www.seeedstudio.com/wiki/Music_Shield_V2.0

Any help appreciated. Many Thanks.

I have tried many options, but there is no way I can play specific music tracks in sequence with the servos.

It is not cleare what you want to do.

Is the servo to move over the range during the time the track plays?
If so you need some way of knowing the time the track will play and make the servo move at the speed so that it takes the same time. You are best measuring it and then you know what time to include in what track.

Grumpy_Mike:
It is not cleare what you want to do.

Is the servo to move over the range during the time the track plays?
If so you need some way of knowing the time the track will play and make the servo move at the speed so that it takes the same time. You are best measuring it and then you know what time to include in what track.

Hello Grumpy_Mike, thanks for your reply.
Actually, I just would like the very basic sequence as below:

servo1 moves from 0 to 90
then
play music track 1
then
servo 2 moves from 45 to 45
then
play music track 2

thanks for your help.
Greg_Paris

Then I can't see your problem.

Use the standard servo library and pick a pin that is not being used by the music shield.
Just follow any standard servo tutorial.
I can only see a problem if the music shield uses the timer that the servo library uses. If that is true then you will have to generate the servo signal with an external chip. Their are plenty of boards arround that do this.

What have you tried so far?

Hello Grumpy_Mike,
thanks for helping me !

I have just tried again with this basic example:

#include <SD.h>
#include <SPI.h>
#include <arduino.h>
#include <MusicPlayer.h>
#include <Servo.h>

Servo myservo3;

void setup() {
myservo3.attach(9);
player.begin(); //will initialize the hardware and set default mode to be normal.
player.setPlayMode(PM_REPEAT_ONE); 
player.keyDisable();
player.scanAndPlayAll();
Serial.begin(9600);  
}

void loop() {

player.play();

player.opNextSong();

myservo3.write(0);
delay(2000);

player.opNextSong();

myservo3.write(90);
delay(5000);
 

}

The only thing I can get is only 1 music track played, with no specific coordination with the servo:

Playing song D_OPEN.MP3 ...
[done].
Playing song D_OPEN.MP3 ...
[done].
Playing song D_OPEN.MP3 ...
[done].
Playing song D_OPEN.MP3 ...

thanks for your ideas and suggestions.
Greg_Paris

I am not familiar with the the music player library but there are two ways of playing a track. One where you wait until the track has finished befor the function returns and one where the track starts playing and then immediately returns.
It looks like player.opNextSong is the latter type. Is there another class method for player that does not return until the song is finished. If so use that but before you call it send the command to move the servo.

Thanks Grumpy_mike, I'll try and use another function this morning

player.playOne("a_open.mp3");

thanks
Greg_Paris