My servo was working perfectly up to this point. All of the wires hooked up to my arduino are correct, the only thing I can think of is sometimes my serial port changes by itself automatically. This is my sketch:
/*
Arduino Servo Scissor sketch
*/
#include <Servo.h>
Servo servoMain; // Define our Servo
void setup()
{
servoMain.attach(6); // servo on digital pin 6
}
void loop()
{
servoMain.write(45); // Turn Servo Left to 45 degrees
delay(1000); // Wait 1 second
servoMain.write(0); // Turn Servo Left to 0 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo back to center position (90 degrees)
delay(0); // Wait 1 second
servoMain.write(135); // Turn Servo Right to 135 degrees
delay(500); // Wait 1 second
servoMain.write(180); // Turn Servo Right to 180 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo back to center position (90 degrees)
delay(1000); // Wait 1 second
}
Sorry about that. There is more load on the servo, the servo is a 90 degree one, the arduino itself blinks, and the code reads through but the servo doesn't work. At the moment I am using my computer to power the arduino, but will be using an outlet later on.
What I mean when I say the "code reads through" is that it uploads normally, and the servo is powered by my laptop as well, it's attached to a breadboard. I'm sorry for not being clear, I'm still fairly new at this.
Thanks.
It is not normal to power servos from the USB connector of the computer. Depending on the servo's size this can pull too much current.
However it sounds like your wiring has gone wrong. Are you using solderless bread board? This is not a very good method of construction and wiring that looks like it is making contact often isn't.
So get your multimeter out and measure the voltage across the servo's supply at the servo motor itself.
The other thing to try is to use an other pin to control the servo as you might have damaged pin 6.
katkatkattkac:
the servo is powered by my laptop as well, it's attached to a breadboard
Powering the servo from the Arduino's power supply is not recommended, although you can sometimes get away with it for small servos that are only lightly loaded. If the problem started when you increased the load on the servo it's quite likely you're just overloading the Arduino. You could try disconnecting the load from the servo and see whether it works OK when it can move freely - if the servo works OK like that it confirms that this is a power supply problem. The solution is to provide a separate power supply for the servo, for example a separate battery pack or regulated wall wart. The battery pack or wall wart power supply ground needs to be connected to the Arduino's ground.