Needing to stop my servo

Hi! I am working on a project to make an auto clicker for my ipad, it consists of a continuous servo that spins one full rotation every 5 minutes when a switch is on, but right now the servo spins and I do not know why, can someone help?

#include <Servo.h>

Servo myservo;

const int buttonPin = 2;
const int spinTime = 3000;
int pos = 0;
int buttonState = 0;

void setup() {
  myservo.attach(9);
  pinMode(buttonPin, INPUT_PULLUP);
}

void loop() {
    buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) {
    myservo.write(180);
    delay(spinTime);
    myservo.write(90);
    delay(300000);
  }
}




  • You can completely stop the servo by detaching the servo.

how?..

myservo.detach(9); //detach servo

  • To move the servo, you need to attach it again . . . .

One rotation in 3 seconds at full speed? Not common...
What servo and what supply you have?

the servo number: FS90R
from FITEC

power supply: my pc

So it makes 2 rotations in 1 second, 6 in 3000ms.

Consider that in your code.

but there is still the issue with detach, how can I fix that? I suppose it would be a library add?


  • Try:

myservo.detach();       //detach servo

1 Like

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