Project Need help Integrating two Arduino Codes

Ok, first the good news: You need to change on your hardware setup one thing to be able to integrate the two programs. At the moment you use pin 10 and pin 11 with analogWrite(). This is a little unfortunate, as pin 10 is linked to Timer1 and pin 11 to timer 2. Timer 2 is used by the Tone library so you create a conflict. If you need 2 pins for analogWrite(), you should make sure to use the pins connected to the same timers so you keep as many timers as possible available for other uses. I would suggest to use pins 5 and 6 for left and right motor speed, those are linked to timer 0 and work safely together with the timer interrupt.

Now the less so good news: You need to rewrite both programs so that the don't use the delay() function and do any waiting inside the loop() function by checking the elapses time for various timers. The tutorial to look at is "Blink without Delay". You can leave any delay() call in setup, nobody cares about those. You also need to get rid of loops inside your functions which takes a lot of time and do this piecewise from loop(). A prime suspect for those are the functions driving your servo. You probably can leave in the calls to delayMicroseconds and pulseIn, the pulseOut for the servo is probably a bad idea, but you need to check that. If the song has unwanted pauses between notes, that's the place to check.

Once you have rewritten both programs this way, the rest will be easy. Merge both files, merge the setup() and loop() functions, check if you don't have conflicting variables and defines and you're done.

Korman