Continous Servo Issue

Hello,
So I am using a Continuous Servo Motor with the Servo Library, except when I do the write() function, 0-90 doesn't change the speed when I alter the numbers in that range, it's just going "reverse" at a constant speed. But when I do 90-180, it changes.

Here is the documentation for this library: Servo/docs/api.md at master · arduino-libraries/Servo · GitHub

Here is my code:

#include <Servo.h>
Servo myservo;

int pos = 0;


void setup() {
  // put your setup code here, to run once:
  myservo.attach(2);
  myservo.write(93);
  delay(1000);

  myservo.write(10);
  delay(500);
  myservo.write(93);
  delay(1000);
  


}

void loop() {
  // put your main code here, to run repeatedly:

}

Please help ASAP.

A continuous servo takes myservo.write(90); as a "stop"... less than 90 means "counterclockwise" and greater than "90" means "clockwise." The farther from "90", the faster. "0" means "full speed CCW" and "180" means "full speed CW."

No.

2 Likes

Forgot to mention. Thats another issue. At 90, it just keeps on moving. At 93, it stops

The values (for "center") will vary when using degrees.

To more accurately control a continuous servo use writeMicroseconds();

  • Sounds okay.

Try this test program, connect servo signal wire to pin 9, forget degrees, enter numbers from 544 to 2400.

/*
 Try this test sketch with the Servo library to see how your
 servo responds to different settings, type a position
 (544 to 2400) in the top of serial monitor and hit [ENTER],
 start at 1472 and work your way toward zero (544) 20 micros
 at a time, then toward 2400. 
*/
#include <Servo.h>
Servo servo;

void setup() {
  // initialize serial:
  Serial.begin(9600); // set serial monitor baud rate to match
                      // set serial monitor line ending to "NewLine"
  servo.write(1472); // should be stop position
  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();
    if(Serial.read() == '\n'){} //skip 1 second delay
    pos = constrain(pos, 544, 2400);
    servo.write(pos);
    Serial.print("microseconds =  ");
    Serial.println(servo.readMicroseconds());
  }
}  

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