Hello, I am using a springrc SM-S4303R continuous rotation servo which I purchased from sparkfun electronics. The problem is that no matter what value I write to the servo it rotates counter clockwise at a constant speed.
I tried using the knob example sketch to narrow down what values changed the behavior of the servo but for every value from 0-2000 the servo rotates ccw at a constant speed.
There have been a few posts with this problem already but none of those suggested fixes seem to work. Here is the code:
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
Serial.begin(9600);
}
void loop()
{
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 2000); // scale it to use it with the servo (value between 0 and 180)
myservo.writeMicroseconds(val); // sets the servo position according to the scaled value
Serial.print("pulse: ");
Serial.println(val);
delay(15); // waits for the servo to get there
}