I connected my servo (AS-18 mg ACOMS) to my Arduino UNO and uploaded the sweep program. Motor did not move, the load LED blinks. This happens when I connect the arduino with my PC. [Case 1, see image]
It works fine when I connect my arduino to a external power supply (12V). [Case 2, see image]
When I connect external supply to positive and negative of servo and pulse wire of servo to arduino's pin 9, it doesn't work. (Arduino is connected to PC in this scenario) [Case 3, see image]
What I want, is to rotate the motor and read the angle in the serial monitor using Serial.print();
I found someone with similar problem and a good explanation here: Servo not working with Arduino - Electrical Engineering Stack Exchange
But the only reply says "use external supply".
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
Serial.begin(9600);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
Serial.println(pos);
}