There might be one, you'd have to check. Here's the test-code I use for this library. It should be fairly simple to extend.
/*
ServoFollowPot
This little program controls a servo with a potentiometer.
The button moave the servo from one end to the other, the potentiometer
sets the speed. 0 = full speed, 1 slowest, 255 fastest.
When pressing the button, the led is turned on to exercise it a little.
Every few seconds the current postion of the servos is reported on the
serial line and whenever the button is pressed.
The circuit:
* LED attached from pin 13 to ground: Button led
* Pushbutton attached to pin 2 from GND
* Linear Potentiometer attached to analog pin 2 from GND and +5V acting
as a voltage splitter. Any value from 10 kOhm to 100 kOhm will work.
* Servo control line attached to pin 12.
* Note: on most Arduinos there is already an LED on the board
attached to pin 13.
*/
#include <VarSpeedServo.h>
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int potPin = 16; // the number of the potentiometer pin (Analog 0)
const int mainPin = 12; // Main servo control line
const int ServoMin = 1000; // Minimum pulse width for servos in ms.
const int ServoMax = 2000; // Maximum pulse width for servos in ms.
const int PotiMin = 0; // Minimum value read from potentiometer
const int PotiMax = 1023; // Maximum value read from potentiometer
const int ButtonDelay = 100; // Time in ms to press button to activate tuning mode
VarSpeedServo myServo; // Servo
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pot and button pin as an input:
pinMode(potPin, INPUT);
pinMode(buttonPin, INPUT);
// Activate internal pull up resistor for tuning button
digitalWrite(buttonPin, HIGH);
// Initialise Servos
myServo.attach (mainPin, ServoMin, ServoMax);
// Initialise Serial communication
Serial.begin (9600);
}
void loop() {
static unsigned long debounce = 0; // variable for reading the pushbutton status
static int buttonstate = HIGH; // variable for reading the pushbutton status
static unsigned long lasttick;
// Report position;
if (millis () - lasttick > 5000) {
lasttick = millis ();
Serial.print ("Position=");
Serial.println (myServo.readMicroseconds());
}
// Read button and debounce.
int buttonnow = digitalRead(buttonPin);
if (millis() - debounce >= ButtonDelay
&& buttonnow != buttonstate) {
buttonstate = buttonnow;
debounce = millis();
switch (buttonstate) {
case LOW:
// Button has just been pressed
digitalWrite(ledPin, HIGH);
// Set the servos
{
int potlast = analogRead (potPin); // Read potentiometer
int speed = map (potlast, PotiMin, PotiMax, 1, 256) & 0xff;
myServo.slowmove ((myServo.readMicroseconds() > ServoMin + 400
? ServoMin + 100 : ServoMax - 100), speed);
// Report pot position
Serial.print ("Speed=");
Serial.println (speed);
}
break;
case HIGH:
// Button has just been released
digitalWrite(ledPin, LOW);
break;
}
}
// Slow down
// delay (50);
}
Korman