Hi,
Here is the code that I am using to control a servo and using serial monitor to debug a variable-
#include <Servo.h>
Servo servo;
int angle = 10;
void setup()
{
Serial.begin(9600);
Serial.println("Ready!");
delay(1000);
servo.attach(8);
servo.write(angle);
}
void loop()
{
// scan from 0 to 180 degrees
for(; angle < 140; angle++)
{
servo.write(angle);
delay(5);
}
Serial.println(angle);
delay(1000);
// now scan back from 180 to 0 degrees
for(; angle > 20; angle--)
{
servo.write(angle);
delay(30);
}
Serial.println(angle);
delay(1000);
}
It works ok, untill I attach the signal pin of servo in the arduino. I am using a sg90 servo directly attach to Arduino. When I don't attach the signal pin the serial monitor works ok. It prints the angle variable as it should. But as soon as I attach the signal pin serial monitor stops printing the angle variable. I am a bit confused. Can someone clarify what I am doing wrong.
Thanks in advance