Motor with Servo Control

Hi,
I am using an arduino Uno R3 to control a motor and a servo.
The motor is using the pololu motor driver 18V15

All three are using a 12V external power source.
The issue I am having is that the motor code seems to be skipped when I add the servo control.
By this I mean I can comment out line 30 (//DIACServo.attach(6)) and the motor will function properly.
The servo will not function for obvious reasons.
If I put line 30 back into the code, however, the motor control code seems to be skipped and the servo moves immediately.

The limit switch is for safety purposes only.

Any assistance would be greatly appreciated.

/****************************************************************************** 
Motro and Servo Control
******************************************************************************/
#include <Servo.h>			//Servo Library

//DC Motor
const int Direction = 4;	//Sets Motor Direction Pin to 4
const int Control = 9;		//Sets Motor Control Pin to 9
char user_input;		//Stores the Input of the User into the Serial Monitor
int LimitReached;		//Upper and Lower Limit State Variable
long int StartOfMotor;		//Variable Used to Store the Millis at the moment the Motor Starts

//Servo Motor
Servo DIACServo;	        //Servo Object to control Servo
int ServoPos = 0;	        //Variable used to store servo position

//Variables To Set
int ServoDelay = 10;
int ServoHoldDelay = 3000;	      
   
void setup(){
//DC Motor
	int LimitReached = 0;			  //Upper and Lower Limit State Variable
//Servo
	//DIACServo.attach(6);			  //Initializes Servo Command is as Pin 6
//Serial Setup
	Serial.begin(115200);			  //Open Serial connection for debugging
//Print function list
	Serial.println("1. Canned Cycle 1");	  //Prints User Selection 1 as Canned Cycle for Demo Purposes in Serial Monitor
	Serial.println();			  //Prints Blank Line in Serial Monitor
//Interupts
	LimitReached = 0;			  //Switch Limit State Variable
	attachInterrupt(0, StrokLimit, FALLING);  //Stroke Limit Interupt
	
}

void loop(){
	user_input = Serial.read();  //Read User Input and Enter Selected Mode
  	if (user_input =='1'){       //Run Canned Cycle for Testing and Demo
		Canned1();}	     //Goto Canned Mode Function
}

void Canned1(){
	digitalWrite(Direction,LOW);			  //Sets Direction to Up
	StartOfMotor = millis();
	while(LimitReached == 0){			  //Checks if limit switch has been triggered.)
		while(millis() != (StartOfMotor + 800)){  //Loop the Upward Motion Until Halfway is Reached
			analogWrite(Control, 100);}	  //Motor Movement
		LimitReached = 1;}			  //Exits Loop
	analogWrite(Control, 0);			  //Stop Motor Movement
	LimitReached = 0;				  //Resets Variable after Loop Exit
	for(ServoPos = 90; ServoPos >= 0; ServoPos -=1){  //Goes from 0 Degrees to 180 Degrees in Steps of 1 Degreee
		DIACServo.write(ServoPos);		  //Tells Servo to go to Position in Variable 'ServoPos' 
		delay(ServoDelay);}			  //Waits 'LookDelay' Variable MS for the Servo to Reach the Position 
	delay(ServoHoldDelay);				  //Waits 'LookHoldDelay' Varialbe ms to Return to Front from Look Position
	for(ServoPos = 0; ServoPos<=90; ServoPos +=1){	  //Goes from 180 Degrees to 0 Degrees in Steps of 1 Degreee                          
		DIACServo.write(ServoPos);		  //Tells Servo to go to Position in Variable 'ServoPos' ' 
		delay(ServoDelay);}			  //Waits 'LookDelay' Variable MS for the Servo to Reach the Position
	Serial.println("Enter New Option");		  //Print Enter New Option in Serial Monitor
	Serial.println();				  //Print Blank Line in Serial Monitor
}


//Reached Either the Upper or Lower Stroke Limit
void StrokLimit(){
	LimitReached = 1;  //Changes Stroke Variable to Stop Movment
}
const int Control = 9;
analogWrite(Control, 100);

The Servo library knocks out PWM on Timer1 (pins 9 and 10). Pick a different PWM pin for Control.

Also note that the code moving the motor and the code moving the servo are both blocking, so the two won’t run at the same time. While the code is in the while loop running the motor the servo won’t move and while the code is in the for loop running the servo the motor won’t move.

You’ve got some other issues, but they’re not going to bite you until later.

For example this:

while(millis() != (StartOfMotor + 800))

Should be written as:

while(millis() - StartOfMotor < 800)

or you’ll run into issues when the millis counter rolls back over to 0.

This loop is not guaranteed to work:

 while(millis() != (StartOfMotor + 800)){  //Loop the Upward Motion Until Halfway is Reached

Firstly millis() skips values occasionally, and you might miss it anyway due to time taken in
your code somewhere. Do the test like this:

 while(millis() - StartOfMotor < 800){  //Loop the Upward Motion Until Halfway is Reached

You need to subtract time values before comparing if you want the code to work across the
result of millis() or micros() wrapping-round.

Thanks Gentlemen,
I put the Motor control on Pin 11.
I was not aware of the Millis Issue either.
The code I had is from a motor control post on stackoverflow.

Both the servo and Motor now function!