0

I am new to Arduino and am trying to figure out servos. Right now I have a toggle button code for the servos. Although I want to know how to speed them up. Is there a way to do this?

Currently, this is my code:

#include <Servo.h>
int button = 5; //button pin, connect to ground to move servo
int press = 0;
Servo servo_7;
Servo servo_8;
Servo servo_9;
Servo servo_10;
boolean toggle = true;

void setup()
{

  pinMode(button, INPUT); //arduino monitor pin state
  servo_7.attach(7); //pin for servo control signal
  servo_8.attach(8);
  servo_9.attach(9);
  servo_10.attach(10);
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press = digitalRead(button);
  if (press == LOW)
  {
    if(toggle)
    {

      servo_7.write(180);
      servo_8.write(180);
      servo_9.write(180);
      servo_10.write(180);
      toggle = !toggle;
    }
    else
    {

      servo_7.write(0);
      servo_8.write(0);
      servo_9.write(0);
      servo_10.write(0);

      toggle = !toggle;
    }
  }
  delay(100);  //delay for debounce
}
  • 1
    Please add your code, since we cannot help you without it. Edit your question accordingly and format the code correctly (There is also a shortcut for it: Strg + K) – chrisl May 12 '18 at 20:26
  • Stop changing the whole question. It is frustrating, that you solved the problem yourself during me writing an answer, and then just changing the question to a complete other problem. If you can solve your problem in this short time, you should not ask a question here. It is not in the scope of this site, to answer questions, that can be easily answered by googling or thinking about it. – chrisl May 12 '18 at 20:54
  • You cannot change the servos speed with the Servo library. It just outputs the value you give as a PWM wave. It is up to your servo to follow it as fast as it can. – chrisl May 12 '18 at 20:55
  • why do you have the servo_7.write(), servo_8.write(), etc code twice ... you only need to have it once – jsotola May 13 '18 at 2:32
1

Normal servos have a speed. It's their speed, and you can't change it. You can make it appear slower by moving in small increments, but you can't actually change the speed it moves.

With constant rotation servos the "angle" dictates the rotation speed, but even with those there is nothing you can do to change the relationship between "angle" and rotational speed.

Other than buying a different servo with a different degrees-per-second rating.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.