merged sketches compile but dont work together

i found this code and it works perfectly, mouth moves to audio nice and smooth

#include "SoftRcPulseOut.h"
#define TEST_PIN 5 
int audio_value = 0;
long lastMsg = 0;
long sleepWindow = 300000; 
SoftRcPulseOut servo;
volatile boolean servosEnabled = false;
volatile boolean ledsOn = true;
volatile unsigned long currentTime = 0;
volatile unsigned long lastLEDtime = 0;
unsigned long resetWait = 120000; 
void setup()
{

 pinMode(TEST_PIN,INPUT); 
 digitalWrite(TEST_PIN,HIGH); 
} 

void loop()
{
  servo_test();
  audio_updates(); 
  if(servosEnabled) 
  {
 action(); 
 SoftRcPulseOut::refresh();
 if((millis() - lastMsg) > sleepWindow)
  detach_servos();
  }
} 
void attach_servos()
{   
    servo.attach(8);
    servosEnabled = true;
}
void detach_servos()
{  
    servo.detach();
    servosEnabled = false;
}
void servo_test()
{
 if(digitalRead(TEST_PIN) == HIGH) return;
 attach_servos();
 SoftRcPulseOut::refresh();
 for(int i = 0; i < 360;i++)
 {
 if(i < 180)
 audio_value = i;
 else
 audio_value = 359 - i;
 action();
 for(int i = 0; i < 10; i++)
 {
   delay(1); 
   SoftRcPulseOut::refresh();
 }
 }
 detach_servos();
}
void audio_updates()
{
 audio_value = 0;
 if(analogRead(A0) < 341) audio_value += 60;
 if(analogRead(A1) < 341) audio_value += 60;
 if(analogRead(A2) < 341) audio_value += 60;

 if(audio_value > 0) 
 {
 lastMsg = millis();
 if(!servosEnabled)attach_servos();
 }
}
void action() { 
  if (!servosEnabled) attach_servos();
  servo.write(audio_value);
  SoftRcPulseOut::refresh();
} 
void set_minmax()
{
 
 servo.setMinimumPulse(map(62,0,150,512,2400));
 servo.setMaximumPulse(map(82,0,150,512,2400));
}

im using this one also and it works perfectly, great random head movement is the result

#include <Servo.h> 
Servo NODservo;                 
Servo TILTservo; 
Servo TURNservo; 

int NOD = 9;                    
int TILT = 10;                  
int TURN = 11;                  
int BLINK = 6;                  
 
int NOD_UP = 50;                 
int NOD_Mid = 90;            
int NOD_DOWN = 100;             

int Tilt_Left = 90;            
int Tilt_Mid = 67;              
int Tilt_Right = 3;             

int Turn_Left = 100;            
int Turn_Mid = 90;               
int Turn_Right = 3;             

boolean lockLow = true;
boolean takeLowTime; 

long randomNOD;                   
long randomTILT;                  
long randomTURN;                   

void randomHeadMotion();
void centerSkull();
void CalibratedMove();
void slowMoveCenter();

void setup()
{
  
  pinMode(BLINK, OUTPUT);            
  digitalWrite(BLINK, LOW);         
  
  NODservo.attach(NOD);             
  TILTservo.attach(TILT);           
  TURNservo.attach(TURN);           
   
  centerSkull();
  
 }
void loop()
{  
   
       slowMoveCenter();
    }

void randomHeadMotion()
{
   digitalWrite(BLINK, LOW);              
   
   int NODlow = 75;
   int NODhigh = 93;
   int TILTlow = 48;
   int TILThigh = 85;
   int TURNlow = 25;
   int TURNhigh = 159;
  
   randomSeed(analogRead(0));                        
   randomNOD = random(NODlow, NODhigh);               
   randomTILT = random(TILTlow, TILThigh);          
   randomTURN = random(TURNlow, TURNhigh);            
   
   int currentNOD = NODservo.read();
   int currentTILT = TILTservo.read();
   int currentTURN = TURNservo.read();
   
   int pos = 0;                            
   int NODpos = randomNOD;
   int TILTpos = randomTILT;
   int TURNpos = randomTURN; 
   
   for(pos = 0; pos < 100; pos += 5)      
   {                                       
     
     if(currentNOD <= randomNOD)
     {
       NODpos = map(pos, 100, 0, randomNOD, currentNOD);  
     }
     else
     {
       NODpos = map(pos, 0, 100, currentNOD, randomNOD);  
     }
    
     if(currentTILT <= randomTILT)
     {
       TILTpos = map(pos, 100, 0, randomTILT, currentTILT);  
     }
     else
     {
       TILTpos = map(pos, 0, 100, currentTILT, randomTILT);   
     }
    
     if(currentTURN <= randomTURN)
     {
       TURNpos = map(pos, 100, 0, randomTURN, currentTURN);  
     }
     else
     {
       TURNpos = map(pos, 0, 100, currentTURN, randomTURN); 
     }
     
     NODservo.write(NODpos);                 
     TILTservo.write(TILTpos);          
     TURNservo.write(TURNpos);               
     delay(10);                                  
     
   } 
   
   randomSeed(analogRead(0));               
   int randomTIME = random(200, 400);       
   delay(randomTIME); 
  
   randomSeed(analogRead(1));                
   randomNOD = random(NODlow, NODhigh);       
   randomTILT = random(TILTlow, TILThigh);    
   randomTURN = random(TURNlow, TURNhigh);   
   
   currentNOD = NODservo.read();
   currentTILT = TILTservo.read();
   currentTURN = TURNservo.read();
   
   randomSeed(analogRead(2));          
   randomTIME = random(200, 600);      
   delay(randomTIME); 
   digitalWrite(BLINK, HIGH);           
}

void centerSkull()
{
  digitalWrite(BLINK, LOW);                
  NODservo.write(NOD_Mid);                 
  TILTservo.write(Tilt_Mid);               
  TURNservo.write(Turn_Mid); 
  delay(500); 
  digitalWrite(BLINK, HIGH);               
}

void CalibratedMove()
{
  digitalWrite(BLINK, LOW);                 

  
  NODservo.write(NOD_Mid);  
  TILTservo.write(Tilt_Mid);  
  TURNservo.write(Turn_Mid); 
  delay(800);  
  
  NODservo.write(NOD_UP);
  delay(800);  
  NODservo.write(NOD_DOWN);
  delay(800);  
  NODservo.write(NOD_Mid);
  delay(800);  

 
  TILTservo.write(Tilt_Left);
  delay(800);   
  TILTservo.write(Tilt_Right);
  delay(800);   
  TILTservo.write(Tilt_Mid); 
  delay(800);

  
  TURNservo.write(Turn_Right);
  delay(800);  
  TURNservo.write(Turn_Left);
  delay(800);   
  TURNservo.write(Turn_Mid);  
  delay(800);
  
  digitalWrite(BLINK, HIGH);               
}



void slowMoveCenter()
{
   digitalWrite(BLINK, LOW);               

   
   randomNOD = NOD_Mid;                    
   randomTILT = Tilt_Mid;                 
   randomTURN = Turn_Mid;                 
   
   
   int currentNOD = NODservo.read();
   int currentTILT = TILTservo.read();
   int currentTURN = TURNservo.read();
   
  
   int pos = 0;                           
   int NODpos = randomNOD;
   int TILTpos = randomTILT;
   int TURNpos = randomTURN; 
   
   for(pos = 0; pos < 100; pos += 5)        
   {                                      
     
     
     if(currentNOD <= randomNOD)
     {
       NODpos = map(pos, 100, 0, randomNOD, currentNOD);  
     }
     else
     {
       NODpos = map(pos, 0, 100, currentNOD, randomNOD);  
     }
     
     
     if(currentTILT <= randomTILT)
     {
       TILTpos = map(pos, 100, 0, randomTILT, currentTILT);  
     }
     else
     {
       TILTpos = map(pos, 0, 100, currentTILT, randomTILT);  
     }
     
    
     if(currentTURN <= randomTURN)
     {
       TURNpos = map(pos, 100, 0, randomTURN, currentTURN);  
     }
     else
     {
       TURNpos = map(pos, 0, 100, currentTURN, randomTURN);  
     }
     
     NODservo.write(NODpos);                  
     TILTservo.write(TILTpos);              
     TURNservo.write(TURNpos);              
     delay(10);                                 
     
   }
    
   digitalWrite(BLINK, HIGH);            
}

but when i merge them together the sketch compiles with no errors but i dont get random head movement, i do get the mouth moving to the audio but its not smooth like before the merge. just need some guidance. thanks in advance

#include "SoftRcPulseOut.h"
#define TEST_PIN 5
#include <Servo.h>
Servo NODservo;                  
Servo TILTservo;
Servo TURNservo;
Servo Mouthservo;

int NOD = 9;                    
int TILT = 10;                  
int TURN = 11;                  
int BLINK = 6;                  

int NOD_UP = 50;                 
int NOD_Mid = 90;             
int NOD_DOWN = 100;             

int Tilt_Left = 90;           
int Tilt_Mid = 67;              
int Tilt_Right = 3;             

int Turn_Left = 100;            
int Turn_Mid = 90;               
int Turn_Right = 3;            
ight = 
boolean lockLow = true;
boolean takeLowTime;

long randomNOD;                  
long randomTILT;                 
long randomTURN;                 


int audio_value = 0;
long lastMsg = 0;
long sleepWindow = 300000; 
SoftRcPulseOut servo;
volatile boolean servosEnabled = false;
volatile boolean ledsOn = true;
volatile unsigned long currentTime = 0;
volatile unsigned long lastLEDtime = 0;
unsigned long resetWait = 120000; 

void randomHeadMotion();
void centerSkull();
void CalibratedMove();
void slowMoveCenter();

void setup()
{
  pinMode(TEST_PIN, INPUT); 
  digitalWrite(TEST_PIN, HIGH); 
  pinMode(BLINK, OUTPUT);           
  digitalWrite(BLINK, LOW);         
  //  Setup Servos
  NODservo.attach(NOD);              
  TILTservo.attach(TILT);            
  TURNservo.attach(TURN);           

  centerSkull();

}

void loop()
{
  servo_test();
  audio_updates(); 
  if (servosEnabled)
  {
    action(); 
    SoftRcPulseOut::refresh();
    if ((millis() - lastMsg) > sleepWindow)
      detach_servos();
    slowMoveCenter();
  }
}
void attach_servos()
{
  Mouthservo.attach(8);
  servosEnabled = true;
}
void detach_servos()
{ 
  servo.detach();
  servosEnabled = false;
}
void servo_test()
{
  if (digitalRead(TEST_PIN) == HIGH) return;
  attach_servos();
  SoftRcPulseOut::refresh();
  for (int i = 0; i < 360; i++)
  {
    if (i < 180)
      audio_value = i;
    else
      audio_value = 359 - i;
    action();
    for (int i = 0; i < 10; i++)
    {
      delay(1);
      SoftRcPulseOut::refresh();
    }
  }
  detach_servos();
}
void audio_updates()
{
  audio_value = 0;
  if (analogRead(A0) < 341) audio_value += 60;
  if (analogRead(A1) < 341) audio_value += 60;
  if (analogRead(A2) < 341) audio_value += 60;

  if (audio_value > 0)
  {
    lastMsg = millis();
    if (!servosEnabled)attach_servos();
  }
}
void action() {
  if (!servosEnabled) attach_servos();
  servo.write(audio_value);
  SoftRcPulseOut::refresh();
}
void set_minmax()
{
   servo.setMinimumPulse(map(62, 0, 150, 512, 2400));
  servo.setMaximumPulse(map(82, 0, 150, 512, 2400));
}
void randomHeadMotion()
{
  digitalWrite(BLINK, LOW);               

  int NODlow = 75;
  int NODhigh = 93;
  int TILTlow = 48;
  int TILThigh = 85;
  int TURNlow = 25;
  int TURNhigh = 159;

  randomSeed(analogRead(0));                         
  randomNOD = random(NODlow, NODhigh);               
  randomTILT = random(TILTlow, TILThigh);           
  randomTURN = random(TURNlow, TURNhigh);           
  
  int currentNOD = NODservo.read();
  int currentTILT = TILTservo.read();
  int currentTURN = TURNservo.read();
  int pos = 0;                           
  int NODpos = randomNOD;
  int TILTpos = randomTILT;
  int TURNpos = randomTURN;

  for (pos = 0; pos < 100; pos += 5)     
  {

     if (currentNOD <= randomNOD)
    {
      NODpos = map(pos, 100, 0, randomNOD, currentNOD);  
    }
    else
    {
      NODpos = map(pos, 0, 100, currentNOD, randomNOD);  
    }

    if (currentTILT <= randomTILT)
    {
      TILTpos = map(pos, 100, 0, randomTILT, currentTILT);  
    }
    else
    {
      TILTpos = map(pos, 0, 100, currentTILT, randomTILT);  
    }

   
    if (currentTURN <= randomTURN)
    {
      TURNpos = map(pos, 100, 0, randomTURN, currentTURN);  
    }
    else
    {
      TURNpos = map(pos, 0, 100, currentTURN, randomTURN);  
    }

    NODservo.write(NODpos);                 
    TILTservo.write(TILTpos);               
    TURNservo.write(TURNpos);               
    delay(10);                              

  }

  randomSeed(analogRead(0));                
  int randomTIME = random(200, 400);       
  delay(randomTIME);

  
  randomSeed(analogRead(1));                
  randomNOD = random(NODlow, NODhigh);      
  randomTILT = random(TILTlow, TILThigh);   
  randomTURN = random(TURNlow, TURNhigh);  


  currentNOD = NODservo.read();
  currentTILT = TILTservo.read();
  currentTURN = TURNservo.read();

   randomSeed(analogRead(2));          
  randomTIME = random(200, 600);      
  delay(randomTIME);
  digitalWrite(BLINK, HIGH);          
}
void centerSkull()
{
  digitalWrite(BLINK, LOW);                 
  NODservo.write(NOD_Mid);                 
  TILTservo.write(Tilt_Mid);               
  TURNservo.write(Turn_Mid);
  delay(500);
  digitalWrite(BLINK, HIGH);               
}
void CalibratedMove()
{
  digitalWrite(BLINK, LOW);                 

 
  NODservo.write(NOD_Mid);
  TILTservo.write(Tilt_Mid);
  TURNservo.write(Turn_Mid);
  delay(800);

 
  NODservo.write(NOD_UP);
  delay(800);
  NODservo.write(NOD_DOWN);
  delay(800);
  NODservo.write(NOD_Mid);
  delay(800);

  TILTservo.write(Tilt_Left);
  delay(800);
  TILTservo.write(Tilt_Right);
  delay(800);
  TILTservo.write(Tilt_Mid);
  delay(800);


  TURNservo.write(Turn_Right);
  delay(800);
  TURNservo.write(Turn_Left);
  delay(800);
  TURNservo.write(Turn_Mid);
  delay(800);

  digitalWrite(BLINK, HIGH);               
}

void slowMoveCenter()
{
  digitalWrite(BLINK, LOW);              
  
  randomNOD = NOD_Mid;                    
  randomTILT = Tilt_Mid;                 
  randomTURN = Turn_Mid;                  

  int currentNOD = NODservo.read();
  int currentTILT = TILTservo.read();
  int currentTURN = TURNservo.read();

  int pos = 0;                          
  int NODpos = randomNOD;
  int TILTpos = randomTILT;
  int TURNpos = randomTURN;

  for (pos = 0; pos < 100; pos += 5)      
  { 

       if (currentNOD <= randomNOD)
    {
      NODpos = map(pos, 100, 0, randomNOD, currentNOD);  
    }
    else
    {
      NODpos = map(pos, 0, 100, currentNOD, randomNOD);  
    }

    if (currentTILT <= randomTILT)
    {
      TILTpos = map(pos, 100, 0, randomTILT, currentTILT);   
    }
    else
    {
      TILTpos = map(pos, 0, 100, currentTILT, randomTILT);  
    }

    if (currentTURN <= randomTURN)
    {
      TURNpos = map(pos, 100, 0, randomTURN, currentTURN);   
    }
    else
    {
      TURNpos = map(pos, 0, 100, currentTURN, randomTURN);  
    }

    NODservo.write(NODpos);               
    TILTservo.write(TILTpos);               
    TURNservo.write(TURNpos);               
    delay(10);                              
  }
    digitalWrite(BLINK, HIGH);           
}

Too much delay in your head movement. During delay, everything else comes to a halt. You need to change the code to time based.
http://forum.arduino.cc/index.php?topic=223286.0

Lilblkshp:
but when i merge them together the sketch compiles with no errors but i dont get random head movement, i do get the mouth moving to the audio but its not smooth like before the merge. just need some guidance. thanks in advance
...

That's a problem I always have too, whenever I grab code somebody else wrote, and that I do not fully get. I may understand the general purpose, and even follow the logic in loop() and other functions, but unless I know all the nuances of every action of the program, it misbehaves.

What I suggest (and what I do) is to completely rewrite the program. Borrow as heavily as you want from the working sketches you have, but re-create all of the decisions, data structures, and variable readings and writings yourself. This will cause you to learn the program using different neural pathways than were created by reading the program. Your comprehension of the code will be much more complete, and your creative additions will improve, both your code, and your understanding of it.

Of course you can black-box large pieces of it. We all do at some point. But if you build the overall structure of the program, you will be able to see and fix these kind of problems using your increased insight.

thanks ill give it a try

Lilblkshp:
thanks ill give it a try

Before you rebuild your code from scratch, BTW not the best idea, just do "find" randomHeadMotion.
You have well self documented code and I assume randomHeadMotion moves head, right?
It is never used. I did not go any further analyzing your code.

So use the other advise and go thru your code line by line ( setup than loop) and see it the LOGIC flow is correct.
Jim

Looks good, I would not change much until it works. Just check the flow.
I did add some stuff to your code , compiler will tell you where.
Just minor things.
You code is first one I have seen on this forum using BLINK as "live" indicator.
Nice touch.
Jim

#include "SoftRcPulseOut.h"
#define TEST_PIN 5
#include <Servo.h>
Servo NODservo;
Servo TILTservo;
Servo TURNservo;
Servo Mouthservo;

int NOD = 9;
int TILT = 10;
int TURN = 11;
int BLINK = 6;

int NOD_UP = 50;
int NOD_Mid = 90;
int NOD_DOWN = 100;

int Tilt_Left = 90;
int Tilt_Mid = 67;
int Tilt_Right = 3;

int Turn_Left = 100;
int Turn_Mid = 90;
int Turn_Right = 3;
ight =
  boolean lockLow = true;
boolean takeLowTime;

long randomNOD;
long randomTILT;
long randomTURN;


int audio_value = 0;
long lastMsg = 0;
long sleepWindow = 300000;
SoftRcPulseOut servo;
volatile boolean servosEnabled = false;
volatile boolean ledsOn = true;
volatile unsigned long currentTime = 0;
volatile unsigned long lastLEDtime = 0;
unsigned long resetWait = 120000;

void randomHeadMotion();
void centerSkull();
void CalibratedMove();
void slowMoveCenter();

void setup()
{
  pinMode(TEST_PIN, INPUT);
  digitalWrite(TEST_PIN, HIGH);
  pinMode(BLINK, OUTPUT);
  digitalWrite(BLINK, LOW); good coding practice useing BLIN as I am alive indicator 
  //  Setup Servos
  NODservo.attach(NOD);
  TILTservo.attach(TILT);
  TURNservo.attach(TURN);
  centerSkull();
}

void loop()
{
  servo_test();
  audio_updates();
  if (servosEnabled)
  {
    action();
    SoftRcPulseOut::refresh();
    if ((millis() - lastMsg) > sleepWindow)
      detach_servos(); servos are mechnical devices - add some delay here , but doe not matter on detach much 
    slowMoveCenter();
  }
}
void attach_servos()
{
  Mouthservo.attach(8);
  servosEnabled = true;
}
void detach_servos()
{
  servo.detach();
  servosEnabled = false;
}
void servo_test()
{
  if (digitalRead(TEST_PIN) == HIGH) return;
  if (condition)  is evlauted to true / HIGH or flas /LOW 
  avoid hard to find bugs by skipping the == 
  if (digitalRead(TEST_PIN))/*  == HIGH)*/  return;
  attach_servos();
  SoftRcPulseOut::refresh();
  for (int i = 0; i < 360; i++)
  {
    if (i < 180)
      audio_value = i;
    else
      audio_value = 359 - i;
    action();
    for (int i = 0; i < 10; i++)
    {
      delay(1);
      SoftRcPulseOut::refresh();
    }
  }
  detach_servos();
}
void audio_updates()
{
  audio_value = 0; reset ?
  if (analogRead(A0) < 341) audio_value += 60; no update , always start with 0
  if (analogRead(A1) < 341) audio_value += 60;
  if (analogRead(A2) < 341) audio_value += 60;
  when all of the above fails AKA > 341
  audio value will be 0 - see line 109
  if (audio_value > 0)
  {
    lastMsg = millis();
    if (!servosEnabled)attach_servos(); not a good coding practice better use separet line but it is OK ! 
  }
}
void action() {
  if (!servosEnabled) attach_servos();
  servo.write(audio_value);
  SoftRcPulseOut::refresh();
}
void set_minmax()
{
  servo.setMinimumPulse(map(62, 0, 150, 512, 2400));
  servo.setMaximumPulse(map(82, 0, 150, 512, 2400));
}
void randomHeadMotion()
{
  digitalWrite(BLINK, LOW);
  are you using blik as an indicator  of what ? if would it be better to have fixed rate?
  yu have random delay between blinks low / high 
  
  int NODlow = 75;
  int NODhigh = 93;
  int TILTlow = 48;
  int TILThigh = 85;
  int TURNlow = 25;
  int TURNhigh = 159;
  randomSeed(analogRead(0));
  randomNOD = random(NODlow, NODhigh);
  randomTILT = random(TILTlow, TILThigh);
  randomTURN = random(TURNlow, TURNhigh);
  int currentNOD = NODservo.read();
  int currentTILT = TILTservo.read();
  int currentTURN = TURNservo.read();
  int pos = 0;
  int NODpos = randomNOD;
  int TILTpos = randomTILT;
  int TURNpos = randomTURN;
  for (pos = 0; pos < 100; pos += 5)
  {
    if (currentNOD <= randomNOD)
    {
    	how about some comment on the map function ,. just to clarify 
      NODpos = map(pos, 100, 0, randomNOD, currentNOD);
    }
    else
    {
      NODpos = map(pos, 0, 100, currentNOD, randomNOD);
    }
    if (currentTILT <= randomTILT)
    {
      TILTpos = map(pos, 100, 0, randomTILT, currentTILT);
    }
    else
    {
      TILTpos = map(pos, 0, 100, currentTILT, randomTILT);
    }
    if (currentTURN <= randomTURN)
    {
      TURNpos = map(pos, 100, 0, randomTURN, currentTURN);
    }
    else
    {
      TURNpos = map(pos, 0, 100, currentTURN, randomTURN);
    }
    NODservo.write(NODpos);
    TILTservo.write(TILTpos);
    TURNservo.write(TURNpos);
    delay(10);
  }
  randomSeed(analogRead(0));
  int randomTIME = random(200, 400);
  delay(randomTIME);
  randomSeed(analogRead(1));
  randomNOD = random(NODlow, NODhigh);
  randomTILT = random(TILTlow, TILThigh);
  randomTURN = random(TURNlow, TURNhigh);
  currentNOD = NODservo.read();
  currentTILT = TILTservo.read();
  currentTURN = TURNservo.read();
  randomSeed(analogRead(2));
  randomTIME = random(200, 600);
  delay(randomTIME);
  digitalWrite(BLINK, HIGH);
}
void centerSkull()
{
  digitalWrite(BLINK, LOW);
  NODservo.write(NOD_Mid);
  TILTservo.write(Tilt_Mid);
  TURNservo.write(Turn_Mid);
  delay(500);
  digitalWrite(BLINK, HIGH);
}
void CalibratedMove()
{
  digitalWrite(BLINK, LOW);
  NODservo.write(NOD_Mid);
  TILTservo.write(Tilt_Mid);
  TURNservo.write(Turn_Mid);
  delay(800);
  NODservo.write(NOD_UP);
  delay(800);
  NODservo.write(NOD_DOWN);
  delay(800);
  NODservo.write(NOD_Mid);
  delay(800);
  TILTservo.write(Tilt_Left);
  delay(800);
  TILTservo.write(Tilt_Right);
  delay(800);
  TILTservo.write(Tilt_Mid);
  delay(800);
  TURNservo.write(Turn_Right);
  delay(800);
  TURNservo.write(Turn_Left);
  delay(800);
  TURNservo.write(Turn_Mid);
  delay(800);
  digitalWrite(BLINK, HIGH);
}

void slowMoveCenter()
{
  digitalWrite(BLINK, LOW);
  randomNOD = NOD_Mid;
  randomTILT = Tilt_Mid;
  randomTURN = Turn_Mid;
  int currentNOD = NODservo.read();
  int currentTILT = TILTservo.read();
  int currentTURN = TURNservo.read();
  int pos = 0;
  int NODpos = randomNOD;
  int TILTpos = randomTILT;
  int TURNpos = randomTURN;
  for (pos = 0; pos < 100; pos += 5)
  {
    if (currentNOD <= randomNOD)
    {
      NODpos = map(pos, 100, 0, randomNOD, currentNOD);
    }
    else
    {
      NODpos = map(pos, 0, 100, currentNOD, randomNOD);
    }
    if (currentTILT <= randomTILT)
    {
      TILTpos = map(pos, 100, 0, randomTILT, currentTILT);
    }
    else
    {
      TILTpos = map(pos, 0, 100, currentTILT, randomTILT);
    }
    if (currentTURN <= randomTURN)
    {
      TURNpos = map(pos, 100, 0, randomTURN, currentTURN);
    }
    else
    {
      TURNpos = map(pos, 0, 100, currentTURN, randomTURN);
    }
    NODservo.write(NODpos);
    TILTservo.write(TILTpos);
    TURNservo.write(TURNpos);
    delay(10);
  }
  digitalWrite(BLINK, HIGH);
}

thanks julyjim, cant take the credit. i found those two online and have been attempting to merge them, to no avail yet. im new to this and have been learning. both work perfectly separately, i just cant get them to work together. i have a three axis skull i built with a fourth servo for the mouth. i just might have to use two boards as i currently have it operating if i cant figure this out. thanks for all the suggestions everyone ill keep at it

moved some stuff around and the mouth servo from the audio works perfect but i still have no head movement let alone random movement. the test pin is an input and it works to test the limits of the mouth servo. tried to remove all spaces so it would fit but it keeps saying im still over the 9000 limit, how do you get around that?