SERVO MOTOR 360 DEGREE S3006

So, I bought a servo motor that rotates 360 degrees
this is the link

Is it possible with this type of motor to rotate it 180 degrees back and forth with an arduino?
I tried the sample code in the arduino program, but the motor rotates abouut 700 degrees and back 500 degrees.
this is the code i used:

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

A continuous rotation "servo" isn't really a servo. You no longer can control its position. Instead of controlling position, you use the pulses to control the servo's speed.

Some servo test code you might try to see just how your continuous rotation servo works.

// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a 
// to decrease) and enter to change servo position 
// (two hands required, one for letter entry and one for enter key)
// use strings like 90x or 1500x for new servo position 
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continuous rotation servo
//int pos=90;

void setup()
{
  myservo.attach(7, 400, 2600); //servo control pin, and range if desired
  Serial.begin(9600);
  Serial.println("serial servo incremental test code");
  Serial.println("type a character (s to increase or a to decrease)");
  Serial.println("and enter to change servo position");
  Serial.println("use strings like 90x or 1500x for new servo position");
  Serial.println();
}

void loop()
{
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }
  if (readString.length() >0) {
    if(readString.indexOf('x') >0) { 
      pos = readString.toInt();
    }

    if(readString =="a"){
      (pos=pos-1); //use larger numbers for larger increments
      if(pos<0) (pos=0); //prevent negative number
    }
    if (readString =="s"){
      (pos=pos+1);
    }

    if(pos >= 400) //determine servo write method
    {
      Serial.println(pos);
      myservo.writeMicroseconds(pos);
    }
    else
    {   
      Serial.println(pos);
      myservo.write(pos); 
    }
  }
  readString=""; //empty for next input
}

I was under the impression that the “Servo” library handles this automatically:-

if(pos >= 400) //determine servo write method
    {
      Serial.println(pos);
      myservo.writeMicroseconds(pos);
    }
    else
    {   
      Serial.println(pos);
      myservo.write(pos);
    }

I was under the impression that the "Servo" library handles this automatically:-

You could check the servo library and see what the break point is above the 180 value.

zoomkat: You could check the servo library and see what the break point is above the 180 value.

I tried to remember earlier, but wasn't sure. I didn't delve into the library because it's too hot to spend long sitting in front of the monitor right now. Obviously, you already know, so you could have quoted it rather than send me to the library. I only asked a simple question.

Obviously, you already know, so you could have quoted it rather than send me to the library. I only asked a simple question.

I too would have to go look. The default upper and lower us limit values are clearly stated in the library. One would have to examine the code to see just how the abstract lower range values like 0 and 180 are mapped to the us values. Also see if there are upper/lower limit values applied to these lower values and how they would be handled if out of bounds.

zoomkat:
I too would have to go look. The default upper and lower us limit values are clearly stated in the library. One would have to examine the code to see just how the abstract lower range values like 0 and 180 are mapped to the us values. Also see if there are upper/lower limit values applied to these lower values and how they would be handled if out of bounds.

Another quick run to the monitor from my fan. :smiley:

The value I had in mind was 544, but I might be wrong. Anything below that is automatically changed to 180 and sent to ‘write()’ rather than ‘writeMicroseconds()’, (if I remember correctly).

I only raised the point because someone pointed it out a couple of weeks ago, and I had a quick look at the library at the time. Until then, I wasn’t aware that using ‘write()’ with values larger than the threshold automatically invoked ‘writeMicroseconds()’. (I’m no expert.)
I wasn’t trying to have a go at you. :slight_smile: