Here is another code I've written just to check the speed control:
#include <Servo.h>
Servo servo1;
float servoSpeed;
#define CALIBRATION_BUTTON_PIN 4
boolean calibrationButtonWasUp = true;
boolean calibrationLedEnabled = false;
float p3 = 0; // manipulator
int inputPin3 = A3;
boolean CCW = false;
void setup() {
// put your setup code here, to run once:
pinMode(CALIBRATION_BUTTON_PIN, INPUT_PULLUP);
servo1.attach(9);
Serial.begin(9600);
}
void loop() {
boolean calibrationButtonIsUp = digitalRead(CALIBRATION_BUTTON_PIN);
if (calibrationButtonWasUp && !calibrationButtonIsUp) {
delay(1000);
calibrationButtonIsUp = digitalRead(CALIBRATION_BUTTON_PIN);
if (!calibrationButtonIsUp) {
if (CCW== false) {
CCW = true;}
else {
CCW = false;
}
}
}
p3 = analogRead(inputPin3);
servoSpeed = float(1500*(p3/1023));
Serial.println(servoSpeed);
if (CCW == false) {
servo1.writeMicroseconds(1500+servoSpeed);}
else {
servo1.writeMicroseconds(1500-servoSpeed);
}
}
Same problem. CW - works just ok - very smooth. CCW - starts moving just when 'servoSpeed' is 181us. Then speed changes stepwise in 4 steps. Seems I need another precise servo.