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);
}