You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+26-21
Original file line number
Diff line number
Diff line change
@@ -1,31 +1,34 @@
1
-
VarSpeedServo
1
+
VarSpeedServo.h
2
2
===============
3
3
4
-
This Arduino library allows the use of up to 8 servos used with an Arduino. Since it uses interrupts, servos can run asynchronously. The libarary also permits the setting of the speed of a move, and a write() call to position can wait and only return when the move is finished.
4
+
The VarSpeedServo.h Arduino library allows the use of up to 8 servos moving asynchronously (because it uses interrupts). In addition, you can set the speed of a move, optionally wait (block) until the servo move is complete, and create sequences of moves that run asynchronously.
5
5
6
-
This code is an adaptation of the standard Arduino Servo library, which was first adapted by Korman and posted on the [Arduino forum](http://forum.arduino.cc/index.php?topic=61586.0) to add the speed capability. Philip van Allen updated it for Arduino 1.0 + and added the ability to to wait for the move to complete.
6
+
This code is an adaptation of the standard Arduino Servo.h library, which was first adapted by Korman and posted on the [Arduino forum](http://forum.arduino.cc/index.php?topic=61586.0) to add the speed capability. Philip van Allen updated it for Arduino 1.0 + and added the ability to to wait for the move to complete.
7
7
8
8
* Supports up to 8 servos
9
9
* Allows simultaneous, asynchronous movement of all servos
10
-
*Speed of the move can be set
11
-
*A servo write() function to set a new position can wait for completion before returning
12
-
*Allows the use of asynchronous sequences of positions, where the servo can go at a specified speed to each position in order
10
+
*The speed of a move can be set
11
+
*The write() function initiates a move and can optionally wait for completion of the move before returning
12
+
*A servo can be sent a sequence of moves (where each move has a position and speed)
13
13
14
14
Sample Code
15
15
----------------------------
16
16
17
-
#include <VarSpeedServo.h>
18
-
19
-
VarSpeedServo myservo; // create servo object to control a servo
20
-
21
-
void setup() {
22
-
myservo.attach(9); // attaches the servo on pin 9 to the servo object
23
-
}
24
-
25
-
void loop() {
26
-
myservo.write(180, 30, true); // move to 180 degrees, use a speed of 30, wait until move is complete
27
-
myservo.write(0, 30, true); // move to 0 degrees, use a speed of 30, wait until move is complete
28
-
}
17
+
```
18
+
19
+
#include <VarSpeedServo.h>
20
+
21
+
VarSpeedServo myservo; // create servo object to control a servo
22
+
23
+
void setup() {
24
+
myservo.attach(9); // attaches the servo on pin 9 to the servo object
25
+
}
26
+
27
+
void loop() {
28
+
myservo.write(180, 30, true); // move to 180 degrees, use a speed of 30, wait until move is complete
29
+
myservo.write(0, 30, true); // move to 0 degrees, use a speed of 30, wait until move is complete
30
+
}
31
+
```
29
32
30
33
Additional examples are included in the distribution and are available in the Arduino Examples section.
31
34
@@ -40,17 +43,19 @@ VarSpeedServo - Class for manipulating servo motors connected to Arduino pins. M
40
43
attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
41
44
default min is 544, max is 2400
42
45
43
-
write(value) - Sets the servo angle of value in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
46
+
write(value) - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
44
47
write(value, speed) - speed varies the speed of the move to new position 0=full speed, 1-255 slower to faster
45
48
write(value, speed, wait) - wait is a boolean that, if true, causes the function call to block until move is complete
46
49
47
50
writeMicroseconds() - Sets the servo pulse width in microseconds
48
51
read() - Gets the last written servo pulse width as an angle between 0 and 180.
49
-
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
52
+
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
50
53
attached() - Returns true if there is a servo attached.
51
54
detach() - Stops an attached servos from pulsing its i/o pin.
52
55
53
-
slowmove(value, speed) - The same as write(value, speed), retained for compatibility with Korman's version
56
+
slowmove(value, speed) - The same as write(value, speed), retained for compatibility with Korman's version
57
+
58
+
stop() - stops the servo at the current position
54
59
55
60
sequencePlay(sequence, sequencePositions); // play a looping sequence starting at position 0
56
61
sequencePlay(sequence, sequencePositions, loop, startPosition); // play sequence with number of positions, loop if true, start at position
0 commit comments