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 Answer 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.
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.servo_7.write()
,servo_8.write()
,etc
code twice ... you only need to have it once