Problems with serial print (using a input sensor & Servomotor)

I have a input sensor attached to my arduino (uno rev3) on pin A0 and a servo motor on digital pin 9.
If I disconnect my servo motor from the arduino and serial print the values that the input gives I get them correctly.
The problem is that when I attach the servo and try to write values to it, the serial monitor does not print any input values anymore.
After I got this problem and try to upload the sketch again to the arduino I get the error message that my com port is already in use.

Can anyone help me?

Code

int volume_2; // Sound volume there

int height_spiral;

#include <Servo.h> 
Servo servo_1;


void setup() {
  servo_1.attach(9);
  Serial.begin(9600);
}

void loop() {
  volume_2 = analogRead(A0);
  Serial.println(volume_2);
  
     height_spiral = abs(220-(volume_2/2.5));
  
  servo_1.write(height_spiral);
  delay(1000);

  
}

and a servo motor on digital pin 9.

How is the servo powered?

the servo is connect to a breadboard (where also the sensor is connected to) both are connect to the 5V and ground of the arduino using the breadboard.

Hi,

Check the two links in my signature for what is happening and how to fix it.

Duane B

rcarduino.blogspot.com