How to modify the below code that the motor works (Turns on) for tamount of time

Hi again and thanks for your time

below is the modified code after removing the part of testing

/*

  • Control DC motor with Smartphone via bluetooth
    */
    int motorPin1 = 3; // pin 2 on L293D IC
    int motorPin2 = 4; // pin 7 on L293D IC
    int enablePin = 5; // pin 1 on L293D IC
    char state;
    boolean messagePrinted = false; //makes sure that the serial only prints once the state
    unsigned long currentTime; //current time used throughout the program
    unsigned long startTime; //start time of period used throughout the program
    unsigned long period = 200; //change this to alter the run period
    boolean timing = false; //flag to indicate that timing is in progress

void setup()
{
// sets the pins as outputs:
pinMode(motorPin1, OUTPUT);
pinMode(motorPin2, OUTPUT);
pinMode(enablePin, OUTPUT);
// sets enablePin high so that motor can turn on:
digitalWrite(enablePin, HIGH);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}

void loop()
{
currentTime = millis(); //current time
//if some date is sent, reads it and saves in state
if (Serial.available() > 0)
{
state = Serial.read();
messagePrinted = false;;
// if the state is '0' the DC motor will turn off
if (state == '0')
{
showState();
motorStop("state 0"); //stop the motor
if (!messagePrinted)
{
Serial.println("Motor: off");
messagePrinted = true;
}
}
// if the state is '1' the motor will turn right
else if (state == '1')
{
showState();
motorRight("state 1"); //turn motor to the right
startTime = currentTime; //start time of 1 second period **************
timing = true;
Serial.println("timing");
if (!messagePrinted)
{
Serial.println("Motor: right");
messagePrinted = true;
}
}
// if the state is '2' the motor will turn left
else if (state == '2')
{
showState();
motorLeft("state 2"); //turn the motor to the left
startTime = currentTime; //start time of timing period **************
timing = true;
Serial.println("timing");
if (!messagePrinted)
{
Serial.println("Motor: left");
messagePrinted = true;
}
}
}
if (timing) //check whether period has ended
{
if (currentTime - startTime >= period) //period has ended
{
timing = false;
motorStop("timing ended");
}
}
}

void motorStop(char * source)
{
Serial.println("in motorStop()");
Serial.print("Called from : ");
Serial.println(source);
digitalWrite(motorPin1, LOW); // set pin 2 on L293D low turn off the motor
digitalWrite(motorPin2, LOW); // set pin 7 on L293D low
}
void motorRight(char * source)
{
Serial.println("in motorRight()");
Serial.print("Called from : ");
Serial.println(source);
digitalWrite(motorPin1, LOW); // set pin 2 on L293D low
digitalWrite(motorPin2, HIGH); // set pin 7 on L293D high
}
void motorLeft(char * source)
{
Serial.println("in motorLeft()");
Serial.print("Called from : ");
Serial.println(source);
digitalWrite(motorPin1, HIGH); // set pin 2 on L293D high
digitalWrite(motorPin2, LOW); // set pin 7 on L293D low
}

void showState()
{
Serial.print("State : ");
Serial.println(state);
}

Also below is the error message

Arduino: 1.6.12 (Windows XP), Board: "Arduino/Genuino Uno"

collect2.exe: error: ld returned 5 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Regards