Stopping continuous servo with digitalWrite and delayMicroseconds

Hello, I am trying to control a continuous servo using the arduino digitalWrite function. I can get the motor to spin clockwise and counter-clockwise, however I was wondering how I can get the motor to stop spinning. What I would like to do is spin the motor for 5 seconds (5000 ms), stop spinning for 5 seconds, and then repeat. Eventually will be moving the time the servo moves to a user input through serial input.

This is the code I have now. Right now it spins briefly and then pauses for 5 seconds. How would I get it to spin for 5 seconds. I have tried putting a delay(5000) after the delayMicroseconds(2000) but it does not appear to work.

int servoPin = 2;

void setup() {
    pinMode(servoPin, OUTPUT);

}

void loop {
    // Set the pin to high to move the motor
    digitalWrite(servoPin, HIGH);
    // Speed of the motor
    delayMicroseconds(2000);
    // Try and stop the motor
    digitalWrite(servoPin, LOW);
    // Wait 5 seconds
    delay(5000);

}

Hello, I am trying to control a continuous servo using the arduino digitalWrite function.

Why? That turns a pin on or off. How is that supposed to control a servo?

There IS a Servo library that makes a lot more sense to use.

I was under the impression that the servo library is for non continuous servo motors, based on angular control (move X degrees).

As well, I assumed that setting the pin to LOW would cut the power to the motor.

I was under the impression that the servo library is for non continuous servo motors, based on angular control (move X degrees).

It can be used for continuous rotation "servo"s, too. Use the writeMicroseconds() method to get the "servo" to stop.

As well, I assumed that setting the pin to LOW would cut the power to the motor.

Totally wrong!

Mark

Some servo test code that might help you figure out how your continuous rotation servo works and its stopping point.

// 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
}