serial freeze when motor turns on

hello,

i am working on a project to control a small 3 volt toy motor through a piezo. i modeled my circuit off of this: http://luckylarry.co.uk/arduino-projects/arduino-control-a-dc-motor-with-potentiometer-and-multiple-power-supplies/
basically replacing the potentiometer with a piezo sensor that turns the motor to HIGH whenever it is pressed. The code freezes and stops looping when the motor turns on, is this a problem in my code, or the way i have it hooked up?

int transistorPin = 10;
int piezo = 0;
void setup() {
pinMode(transistorPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
piezo = analogRead(0) / 4;
Serial.println(piezo);

if (piezo < 100)
{analogWrite(10, LOW);}
else
{analogWrite(10, HIGH);}

delay(500);
}

Could this somehow be related to the problem I have, described here: http://arduino.cc/forum/index.php/topic,73295.0.html

Basically my circuit works correctly until I hook up a motor to it. The system becomes very unstable the moment I turn the motor on. I will try adding a capacitor to the motor, to protect the system from interference. My code also freezes (the program stops looping completely) and the serial goes unresponsive.

possibly? did adding a cap work for you? i was also thinking that it might work better if the piezo value is read through interrupts?

When a circuit freezes or misbehaves when a motor is turned on the problem is always one of insufficient supply decoupling:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html