Interactive Cuckoo Clock, Code Problems with servo and stepper motors

So I'm trying to create this interactive cuckoo clock where it's functioning normally through the use of servo and stepper motors and when activated by a PIR sensor the clock hands go backwards and the cuckoo bellows sound off. I've been able to get the sensor part of the code down but now I'm in a 2nd servo motor to act as the pendulum that moves underneath it.

The problem is now when I've added in the 2nd servo(myservo1, servoPin1), the stepper motor does not move. I don't believe it's a power thing because I have the stepper hooked up to its own 9v battery. The first motor which is activated by the PIR sensor works as it should, but it's only when I comment out the constant moving servo that the stepper motor works again. I've tried different placements of the servo part of the code but nothing has worked so far.

Help would be much appreciated!

// This Arduino example demonstrates bidirectional operation of a 
// 28BYJ-48, using a ULN2003 interface board to drive the stepper.
// The 28BYJ-48 motor is a 4-phase, 8-beat motor, geared down by
// a factor of 68. One bipolar winding is on motor pins 1 & 3 and
// the other on motor pins 2 & 4. The step angle is 5.625/64 and the 
// operating Frequency is 100pps. Current draw is 92mA. 
////////////////////////////////////////////////
#include <Servo.h>

Servo myservo;  //servo for bellows

Servo myservo1;  //servo for ticking

int pos= 0;
 
int calibrationTime = 5;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int lowIn;
long unsigned int pause = 5000; 

boolean lockLow = true;
boolean takeLowTime; 

int servoPin1 = 6;  //servo pin set for ticker
int servoPin = 3;   //servo pin set for bellows
int pirPin = 2;     //pir pin set
//declare variables for the motor pins
int motorPin1 = 8;    // Blue   - 28BYJ48 pin 1
int motorPin2 = 9;    // Pink   - 28BYJ48 pin 2
int motorPin3 = 10;    // Yellow - 28BYJ48 pin 3
int motorPin4 = 11;    // Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)

int motorSpeed = 2000;  //variable to set stepper speed/higher the number the slower the rotation//figure out speed for it to turn in hour/orhow the clock is set
int count = 0;          // count of steps made
int countsperrev = 512; // number of steps per full revolution
int lookup[8] = {B01000, B01100, B00100, B00110, B00010, B00011, B00001, B01001};

//////////////////////////////////////////////////////////////////////////////
void setup() {
  //declare the motor pins as outputs
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
  pinMode(pirPin, INPUT);
  myservo.attach(3);
  myservo1.attach(6);
  pinMode (servoPin1, OUTPUT);
  pinMode(servoPin, OUTPUT);
  Serial.begin(9600);
}



//////////////////////////////////////////////////////////////////////////////
void loop(){
  
      for(pos = 20; pos < 150; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(5);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 150; pos>=20; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(5);                       // waits 15ms for the servo to reach the position 
  }
  
  //if (digitalRead(pirPin) == HIGH) //does half rotation
  if(count < countsperrev )
    clockwise();
    //servo();
  else if (digitalRead(pirPin) == HIGH) //does full rotation
//  else if (count == countsperrev * 2)
      count = 0;   
  else  
   anticlockwise();
  count++; 

 if(digitalRead(pirPin) == HIGH){
    
    {
      myservo.write(180);
      delay(5);
    }

    if(lockLow){
      lockLow = false;
      Serial.println("---");
      Serial.println("motion detected at");
      Serial.println(millis()/100);
      Serial.println("sec");
      delay(5);
    }
    takeLowTime = true;
  }

  else if(digitalRead(pirPin) == LOW){
    if(takeLowTime){
      lowIn =millis();
      takeLowTime = false;
      myservo.write(1500);
      delay(5);

    }

    if(!lockLow && millis() - lowIn > pause){
      lockLow = true;
      Serial.println("motion ended at");
      Serial.print((millis() - pause)/100);
      Serial.println ("sec");
      delay(5);
      
    }
  }
   

  
}

//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 1 to 4
//delay "motorSpeed" between each pin setting (to determine speed)
void anticlockwise()
{
  for(int i = 0; i < 8; i++)
  {
    setOutput(i);
    delayMicroseconds(motorSpeed);
  }
}

void clockwise()
{
  for(int i = 7; i >= 0; i--)
  {
    setOutput(i);
    delayMicroseconds(motorSpeed);
  }
  
}


void setOutput(int out)
{
  digitalWrite(motorPin1, bitRead(lookup[out], 0));
  digitalWrite(motorPin2, bitRead(lookup[out], 1));
  digitalWrite(motorPin3, bitRead(lookup[out], 2));
  digitalWrite(motorPin4, bitRead(lookup[out], 3));
}

Yes! I'm having the same issue. I'm trying to intermittently turn a stepper motor and intermittent also, a servo. Not even at the same time either! the stepper works fine...the servo works as it should but, together ...nothin'!

I too have tried moving stuff around in the code...changing the order in which they are read....mixing the two pin commands...etc. etc.

I know it can be done as many robots can do it....but for some reason I cant get the code to work..I gave up but, really really need to get this to work.
My stepper commands are different but, overall we are using the same sources for our code parts.

This is the kind of thing that causes trouble

      for(pos = 20; pos < 150; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(5);                       // waits 15ms for the servo to reach the position 
  } 

  for(pos = 150; pos>=20; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo1.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(5);                       // waits 15ms for the servo to reach the position 
  }

150-20= 130
130*5=650
doing it twice = 1300 That;s 1.3 WHOLE SECONDS! that your arduino has been obsessing over this servo! Paying no attention to anything else.

Instead of doing it all at once like this, you should just do it bit by bit, every time through the LOOP.

//Add these three varialbles OUTSIDE the loop to keep track of where we're at
int servo1Doings=1;  //0 not on the move; 1 going up; 2 going down;
int servo1Pos=20;  //current position of servo
unsigned long servo1LastStep=0;//used to hold when the last move of servo 1 was made

void loop(){
  unsigned long t=millis();//use this to evaluate what we should be doing now
   
    //only do something if the servo is due to be moved again
    if((t-servo1LastStep)>5)
      {switch(servo1Doings)
         {case 1: 
                servo1Pos++;
                  myservo1.write(pos);
                  if(servo1Pos>149)
                   servo1Doings=2;
                break;
          case 2:
               servo1Pos--;
               myservo1.write(pos);
               if(servo1Pos<21)
                   servo1Doings=1;
                break;       
         } 
       servo1LastStep=t;//update our note of when we last moved this servo
     }

//ETC...

BTW that 5 is not 5 itterations of the loop, it's 5 milliseconds. So it represents a few hundred itterations of the loop (assuming there are no more delays).