need help with servos

could someone help me combine these two sketches
I am new to this and would greatly appreciate some help
what I would like to do is trigger the random servo movement with the pir and only move servos when pir triggers my audio

 * //////////////////////////////////////////////////
 * //making sense of the Parallax PIR sensor's output
 * //////////////////////////////////////////////////
 * Switches a LED according to the state of the sensors output pin.
 * Determines the beginning and end of continuous motion sequences.
 * @author: Kristian Gohlke / krigoo (_) gmail (_) com /
 * @date:   3. September 2006 
 * kr1 (cleft) 2006 
 * released under a creative commons "Attribution-NonCommercial-ShareAlike 2.0" license
 * The Parallax PIR Sensor is an easy to use digital infrared motion sensor module. 
 * (
 * The sensor's output pin goes to HIGH if motion is present.
 * However, even if motion is present it goes to LOW from time to time, 
 * which might give the impression no motion is present. 
 * This program deals with this issue by ignoring LOW-phases shorter than a given time, 
 * assuming continuous motion is present during these phases.
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 1;        
//the time when the sensor outputs a low impulse
long unsigned int lowIn;         
//the amount of milliseconds the sensor has to be low 
//before we assume all motion has stopped
long unsigned int pause = 5;  
boolean lockLow = true;
boolean takeLowTime;  
int pirPin = 3;    //the digital pin connected to the PIR sensor's output
int ledPin = 13;
int mp3Pin = 2;

void setup(){
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(mp3Pin, OUTPUT);  //set mp3Pin as an output
  digitalWrite(pirPin, LOW);
  digitalWrite(mp3Pin, LOW); //set mp3Pin to low ("off")
  //give the sensor some time to calibrate
  Serial.print("calibrating sensor ");
    for(int i = 0; i < calibrationTime; i++){
    Serial.println(" done");
    Serial.println("SENSOR ACTIVE");
void loop(){
     if(digitalRead(pirPin) == HIGH){
       digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
       digitalWrite(mp3Pin, HIGH);  //send a signal on the mp3Pin to have the relay trigger the sound
       delay(2); //wait
       digitalWrite(mp3Pin, LOW);  //bring the mp3Pin back low so the relay closes and doesn't loop the sound
       digitalWrite(mp3Pin, HIGH);  //send a signal on the mp3Pin to have the relay trigger the sound
       digitalWrite(mp3Pin, LOW);
         //makes sure we wait for a transition to LOW before any further output is made:
         lockLow = false;            
         Serial.print("motion detected at ");
         Serial.println(" sec"); 
         takeLowTime = true;
     if(digitalRead(pirPin) == LOW){       
       digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state
       digitalWrite(mp3Pin, LOW);
        lowIn = millis();          //save the time of the transition from high to LOW
        takeLowTime = false;       //make sure this is only done at the start of a LOW phase
       //if the sensor is low for more than the given pause, 
       //we assume that no more motion is going to happen
       if(!lockLow && millis() - lowIn > pause){  
           //makes sure this block of code is only executed again after 
           //a new motion sequence has been detected
           lockLow = true;                        
           Serial.print("motion ended at ");      //output
           Serial.print((millis() - pause)/1000);
           Serial.println(" sec");

 * ScaryShiftServoEyeballs.pde --
 *  Get two eyeballs, hook a servo to each one, 
 *  then mount that on a 'head' and connect a servo to that.
 *  This sketch will make the eyes and head "look around" in a shifty fashion.
 *  Add sensors to make it look at things!
 * 2009, Tod E. Kurt,

#include <Servo.h> 
Servo servoHead; 
Servo servoEyeL; 
Servo servoEyeR;

int posHead;
int posEye;
int posHdest, posEdest;  
int wait;
int rate = 2;

void setup() 

  posHdest = posHead = 90;
  posEdest = posEye = 90;
void loop() 
    if( wait == 0 ) {
        posHdest = random(70,110);  // move had between 70-110 degrees
        posEdest = random(40,140);  // move eyes between 40-140 degrees
        wait = random(150,450);     // between 1.5 secs & 4.5 secs
    else {
        posHead = slew_servo( posHead, posHdest, rate);
        posEye  = slew_servo( posEye,  posEdest, rate);
    servoHead.write( posHead );
    servoEyeL.write( posEye  );
    servoEyeR.write( posEye  );    


// return new pos from current pos, dest and rate
int slew_servo( int pos, int dest, int rate) 
    int diff = pos - dest;
    if( diff == 0 ) return pos;
    else if( diff > -rate ) pos++;
    else if( diff <  rate ) pos--;
    if(      diff > 0 ) pos -= rate;
    else if( diff < 0 ) pos += rate;
    return pos;

Moderator edit: tags added.

could someone help me combine these two sketches

What help do you need? If you understand what each does, then combining them will take about 3 minutes.

Each one defines some global variables. Add the ones from one sketch to the other.

Each does some stuff, once, in setup(). Move the stuff from one setup() to the other.

Each does some stuff on every pass through loop. One works the way you want. The other doesn't. Figure out where in the first sketch the stuff from the second sketch should happen, and move that stuff there.