make servo motor to increase/decrease degree

I'm trying to make servo motor(I am using FT90R) to increase or decrease degrees according to user choice.
I've created an code that get input from the user via Serial and according to the input the motor increase or decrease.
But for some reason, when I call each of one of the function the motor start working without a break. do I miss something over here?

#include <Servo.h>

Servo servo1;  
int currentAngle = 0;
String readString;
void setup()
{
   servo1.attach(8);
   Serial.begin(9600); 
}
void increaseServo(){
  Serial.println('+');
  currentAngle += 5;
  servo1.write(currentAngle);
  delay(15);
}
void decreaseServo(){
  Serial.println('-');
  currentAngle -= 5;
  servo1.write(currentAngle);
  delay(15);
}
void loop() 
{ 
  while(Serial.available()>0) //Allocating the data from Serial Monitor.
  { 
    delay(3);  
    char c = Serial.read();
    readString += c;    
  }
  readString.trim();
  if (readString.length() > 0) {
    if(readString == "+"){ //increase
      increaseServo();
    }else if(readString == "-"){ //decrease
      decreaseServo();
    }
    readString="";
  }
  delay(1000);
}

Thanks for the help.

he motor start working without a break.

I would guess that you have a continuous rotation "servo"

If so, then you cannot control its angle, only its speed and direction

Normal Servo write() values are from 0 to 180 with the centre at 90. So starting from 0 then subtracting 5 from it makes no sense.

But your real problem is that the FEETECH FT90R is a continuous rotation servo. I.e. it is not a normal servo, it has NO position control. The different write() values just control direction and speed of rotation. You need a different servo.

Steve

UKHeliBob:
I would guess that you have a continuous rotation "servo"

If so, then you cannot control its angle, only its speed and direction

slipstick:
Normal Servo write() values are from 0 to 180 with the centre at 90. So starting from 0 then subtracting 5 from it makes no sense.

But your real problem is that the FEETECH FT90R is a continuous rotation servo. I.e. it is not a normal servo, it has NO position control. The different write() values just control direction and speed of rotation. You need a different servo.

Steve

Thank you for your answers.
Do you have any suggestions of the servo motor I need which have the same dimensions?

Do you have any suggestions of the servo motor I need which have the same dimensions?

I would need to do some research on the internet to find a replacement. You might as well do that yourself

Eshk12:
Thank you for your answers.
Do you have any suggestions of the servo motor I need which have the same dimensions?

The incredibly well-known SG90 is approximately the same size, so is the MG90 if you prefer metal gears. That's a fairly standard size for micros servos and there are hundreds of them.

Steve

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.