I'm having a minor novice problem here, but I can't seem to do the right combination of keyword searches to quite find the answer if it's already out there.
I am setting up a very simple exercise: wiring a Parallax Continuous Rotation Servo to an Arduino Uno board. The servo is powered by an external AA battery case, no problem there. The Arduino is being powered by its USB for now. The servo is connected via the usual 3-wire arrangement to power, ground and pin 13 on the Arduino.
The servo is a PWM job, and rotates clockwise at 1.3, coming to a stop at 1.5. I have already done the pot calibration so that it absolutely stops at 1.5.
I have been able to successfully get the servo to rotate 1 full 360 turn, then stop. The idea is that every time someone pushes a button, the wheel attached to the servo will rotate 1 time and stop (it is not intended to ever go in the other direction).
The problem I'm having is, with everything else working fine: every time I re-set the board or re-upload the program to test, or simply turn the power on to everything to "start," the servo "kicks" backwards a few degrees (in other words, I want it to rotate cleanly from a stop point and then stop again, each time...I don't want it always keep 'kicking back' a quarter-turn before operating.
Do I have to just keep the thing continually powered-on once I have it all assembled? Once it's up and running, it responds fine and doesn't do this kick-back, it only does it upon a cold power-up or re-set of the board or re-upload of the code. Or is it possibly that there still isn't sufficient power from the 4xAA battery case to the servo, and this "kick back" is some symptom of low power or a surge during the initial load?
I've searched the various boards here and on Parallax and other hobbyist sites but couldn't find this same issue. I'm not sure if it's the servo, the power source, or maybe the code I'm using.
I'm just using a very basic code setup:
#include <Servo.h>
Servo myServo; // Create Servo object to control the servo
void setup() {
myServo.attach(13); // Servo is connected to digital pin 13
myServo.writeMicroseconds(1300); //Rotate clockwise for 1 full rotation
delay(1264);
myServo.writeMicroseconds(1500); //Then stop
}
void loop() {
}