Continuous Rotation Servo controlled incrementally with Rotary encoder.

Hey Guys, looking for a bit of help. I want to be able to control a continuous servo incrementally (forward, backwards) with a rotary encoder, as well as a joystick…same motion just different types of control methods…

I’m super new at this, but i somehow managed to piece together a code that seems to work. Problem is when i turn the rotary encoder it feels pretty good in relation with the servo movement, however if i turn it to quick it seems to stutter a bit and get confused for a second. I believe it’s due to the fact that i have no idea what i’m doing and somehow got lucky. I’d like to control the servo with the rotary encoder like it’s 2021 and we somehow merged with robots. I know i may be using the wrong parts for the job. I already have it working with a stepper motor, but i can’t get the feel right. End goal is to use it with a mini linear actuator type device.

Using an SPT6325LV-360 servo:
https://www.amazon.ca/Digital-Continuous-Rotation-Robots-Accessories/dp/B07T7GFRKT/ref=sr_1_7?crid=D94X73UBYK79&dchild=1&keywords=continuous+rotation+servo&qid=1598499541&sprefix=continuous+rotation%2Caps%2C191&sr=8-7

This Joystick:
https://www.amazon.ca/IZOKEE-Joystick-Breakout-Controller-Raspberry/dp/B087GD57FM/ref=sr_1_fkmr0_2?dchild=1&keywords=ZOKEE+5+Pcs+Joystick+Game+Breakout+Controller+Sensor+KY-023+Module+for+Arduino+PS2+and+Raspberry+Pi&qid=1598499679&sr=8-2-fkmr0

Arduino Uno Board

Here’s the code

#include <Servo.h>
#define inputCLK 4
#define inputDT 5
#define potpin A3
Servo myservo;
int val1;
int counter = 1500;
int currentStateCLK;
int previousStateCLK;

void setup() {
  pinMode (inputCLK, INPUT);
  pinMode (inputDT, INPUT);
  Serial.begin (9600);
  myservo.attach(9);
  previousStateCLK = digitalRead(inputCLK);

}

void loop() {
  counter = 1500;
  val1 = analogRead(potpin);
  val1 = map(val1, 0, 1023, 1000, 2000);
  myservo.write(val1);
  //Serial.println(val1);
  {
    currentStateCLK = digitalRead(inputCLK);
    if (currentStateCLK != previousStateCLK) {
      if (digitalRead(inputDT) != currentStateCLK) {
        counter --;
        if (counter = 2000) {
          counter = 2000;
        }

      } else {
        counter ++;
        if (counter = 1000) {
          counter = 1000;
        }

      }


      myservo.writeMicroseconds(counter);
      //Serial.print(val);
      Serial.println(counter);
      delay(25);


    }

    previousStateCLK = currentStateCLK;

  }
}

I feel like i’m a million computer clickity clacks away from solving this issue. If i spend a month on this my girlfriend will probably break up with me…Please help!

You cannot control the position of a continuous servo, only the rotation speed. 90 degrees or 1472 microseconds is standstill, the further you move toward 1000 for one direction or 2000 the other, the faster it rotates. No way to tell what position.
Here’s a test sketch:

/*
 Try this test sketch with the Servo library to see how your
 servo responds to different settings, type a position
 (0 to 180) or if you type a number greater than 180 it will be
 interpreted as microseconds(544 to 2400), in the top of serial
 monitor and hit [ENTER], start at 90 (or 1472) and work your
 way toward zero (544) 5 degrees (or 50 micros) at a time, then
 toward 180 (2400). 
*/
#include <Servo.h>
Servo servo;

void setup() {
  // initialize serial:
  Serial.begin(9600); //set serial monitor baud rate to match
  servo.write(90);
  servo.attach(9);
  prntIt();
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int pos = Serial.parseInt();
    pos = constrain(pos, 0, 2400);
    servo.write(pos);
    prntIt();
  }
}
void prntIt()
{
  Serial.print("  degrees = "); 
  Serial.print(servo.read());
  Serial.print("\t");
  Serial.print("microseconds =  ");
  Serial.println(servo.readMicroseconds());
}

I appreciate the response. I am aware of the lack of positioning increments. I’m not looking to keep track of the position of the servo, hence the use of microseconds. Just looking to refine that code to make the movement a bit smoother than what I have now. It might be the best I can get and I’m fine with that. But was just looking for a way to refine the code to make the motion smoother and more Intuitive. I appreciate any advice given.