So I just received an arduino yesterday and have been playing around with it.
I have been trying to hook up a simple servo and its doing something odd.
Here is the code I am using:
#include <Servo.h> // servo library
Servo servo1; // servo control object
void setup()
{
servo1.attach(9);
}
void loop()
{
servo1.write(90); // Tell servo to go to 90 degrees
delay(1000); // Pause to get it time to move
servo1.write(180); // Tell servo to go to 180 degrees
delay(1000); // Pause to get it time to move
servo1.write(0); // Tell servo to go to 0 degrees
delay(1000); // Pause to get it time to move
}
Its supposed to go to half it’s distance, then full, then back to 0.
Instead of doing what I wrote in the code, the servo slowly moves forward maybe a millimeter every second until it hits the end, where it can’t go any farther. All the while, my computer constantly keeps making the sound it does when a usb device is connected every second in sync with the motor. I have not had any other issues with my simple LED circuits I made yesterday.
The servo has the brown wire going to GRD, the red to the 5V and the white to the 9 pin on the arduino.
Any idea of what could be going wrong?