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
}
asked May 12, 2018 at 20:24
4
  • 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) Commented May 12, 2018 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. Commented May 12, 2018 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. Commented May 12, 2018 at 20:55
  • why do you have the servo_7.write(), servo_8.write(), etc code twice ... you only need to have it once Commented May 13, 2018 at 2:32

1 Answer 1

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.

answered May 12, 2018 at 21:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.