Servo speed while using toggle code

I made a code that toggled a servo 0-180 degrees with a button and I was wondering if I could speed up the servo. I have seen codes that do this, although I have been told widely that it isn't possible to do with an Arduino UNO (The board I am using in this project.) This is my current code:

#include <Servo.h>
int button = 5; //button pin, connect to ground to move the 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);

servo_7.write(0);
servo_8.write(0);
servo_9.write(0);
servo_10.write(0);
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
}

Any ideas on how to speed up the servo?

, although I have been told widely that it isn't possible to do with an Arduino UNO

Quite correct, you can also not do it with any micro controller or any other electronics. This is because the speed is controlled by the internal electronics of the servo and are not accessible through software.

The only thing you can do is to make your own servo from an Arduino motor and some form of feedback device.

I have seen codes that do this,

I doubt it, can you post a link to it.

I have an idea. What if I put a gear on a servo, and a smaller gear on a potentiometer and gear it right so that I turn the servo with the gear on it at regular speed, and that gear ratio turns the potentiometer fast so that the servos move fast? It would work, but is it overkill? Is the juice really worth the squeeze?

Servos come in many different varieties. You can always jut buy a faster one. Or at least run the one you have on the highest voltage it can tolerate.

Steve

Ah, so running more voltage through a servo will make it faster? I thought it was at a basic speed, How would I run more than 5V through an Arduino though. Would I need a power bus on it?

Grumpy_Mike:
I doubt it, can you post a link to it.

int i = 10;
#include<Servo.h>
Servo myServo;
void setup() {

Serial.begin(9600);
myServo.attach(9);
}

void loop() {

if(i>=10){
delay(0);
Serial.print(i);
myServo.write(i);
i++;
if(i==160){
delay(3000);

i=9;
}
}
if(i<10) {
myServo.write(10);
delay(3000);
i=10;

}
}

This code isn't formatted, but I used this before and it can slow down the servo by delaying a few microseconds in between turns. And it somehow it makes my Towerpro Servo go faster than normal if I change the delay to 0. You can analyze this code if you like, but I began coding yesterday and am not sure what half of it means.

Nicholas_Walsh:
Ah, so running more voltage through a servo will make it faster? I thought it was at a basic speed, How would I run more than 5V through an Arduino though. Would I need a power bus on it?

Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
How are you powering your servo?

You need to look at the specification/data of your servo before doing anything power supply wise.

Also look in the spec, it should give a speed figure, ie degrees/sec .

Tom... :slight_smile:

This code isn't formatted, but I used this before and it can slow down the servo by delaying a few microseconds in between turns.

Slowing down a servo is easy.

And it somehow it makes my Towerpro Servo go faster than norma

Only if the software driving your servo was slowing it down even more that that code.

How would I run more than 5V through an Arduino

Basically you don’t, you still connect a 5V signal to the servo, but you supply the power to it from a different supply / regulator.