Simple Serial Communication Problem

Hi all,
I'm working on a basic project with my robot. The idea is that the robot moves forward until it hits an object with the bumper, then it takes a 90º turn and stops. <-- This all works as expected. Here is my problem area --> Eventually I'm going to take this concept further for data collection purposes, but right now it's simple (no data collection). After the robot stops, I want to make a serial connection and send messages to the computer screen. The problem that I'm having is that my code only works if the robot is hooked up to the robot via USB through the entire program, rather than just in the serial communication code section of the program. How can I modify my code so that the robot is only required to be hooked up to the computer when it actually needs to be?
Here is my code:

int touchCountThreshold = 1;
int motor = 5;
int motorDirection = 4;
int touch = 2;
int touchVal = 0;
int button = 3;
int buttonVal = digitalRead(button);
int touchCount = 0;

void setup () {
  pinMode(touch, INPUT);
  pinMode(button, INPUT);
  pinMode(motor, OUTPUT);
  pinMode(motorDirection, OUTPUT);
  while(buttonVal == HIGH) {
    buttonVal = digitalRead(button);
    if(buttonVal == LOW) {break;}
  }
}

void loop () {
  touchVal = digitalRead(touch);
  if (touchVal == LOW && touchCount < touchCountThreshold) {
    analogWrite(motor, 0);
    touchCount++;
    digitalWrite(motorDirection, HIGH);
    analogWrite(motor, 255);
    delay(4000);
    analogWrite(motor, 0);
  }
  else if(touchVal == HIGH && touchCount < touchCountThreshold) {
    digitalWrite(motorDirection, LOW);
    analogWrite(motor, 255);
  }
  if (touchCount >= touchCountThreshold) {
    analogWrite(motor, 0);
    buttonVal = digitalRead(button);
      if(buttonVal == LOW) {
      delay(100);
      Serial.begin(9600);
      Serial.println("Connected");
      Serial.end();
    }
  }
}

How can I modify my code so that the robot is only required to be hooked up to the computer when it actually needs to be?

What is on the other end of the serial connection? Does that application handle the situation of the Arduino coming and going?

This requirement doesn't really make sense. When the robot stops, are you going to run over to it and connect it to the PC so that it can print "I stopped"? What is the purpose of that? You have to know that the robot stopped so you can connect the cord so that the robot can tell you it stopped.

Generally, when a PC connects to the serial port, the Arduino is reset. Have you modified your Arduino so this doesn't happen? Do you plan to?

What is on the other end of the serial connection?

My Arduino program on my Mac.

This requirement doesn't really make sense. When the robot stops, are you going to run over to it and connect it to the PC so that it can print "I stopped"? What is the purpose of that? You have to know that the robot stopped so you can connect the cord so that the robot can tell you it stopped.

Eventually I'm going to take this concept further for data collection purposes

Generally, when a PC connects to the serial port, the Arduino is reset. Have you modified your Arduino so this doesn't happen? Do you plan to?

This is the whole point of my post. I want to know if there is a way to get around the reset function.

I want to know if there is a way to get around the reset function.

Then, you should have asked that back at the beginning.

http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

Thank you for the help.