Skip to content

Commit 058f633

Browse files
committed
Merge branch 'release/v1.3.0'
2 parents 701a713 + 87d1a42 commit 058f633

File tree

6 files changed

+384
-156
lines changed

6 files changed

+384
-156
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
# Servo Hardware PWM Library for Arduino Mega
22

3-
This library allows Arduino/Genuino Mega boards to control up to **6 servos** with the integrated **16-bit hardware PWM timer/counter**.
3+
This library allows Arduino/Genuino Mega boards to control up to **9 servos** with the integrated **16-bit hardware PWM timer/counter**.
44
16-bit hardware timer/counter (timer3, timer4 and timer5) are used to control the servos.
55

66
Unlike the original Servo.h library, this library does not use timer1.
77
The advantage here is that when using the Wire.h library no fluctuations in the pulse width occur.
88
In addition, I/O registers are addressed directly and not via the digitalWrite()-function (as in Servo.h).
99

10-
Possible output pins are **pin 2, 3, 7, 8, 44,** and **45**.
10+
Possible output pins are **pin 2, 3, 5, 6, 7, 8, 44, 45** and **46**.
1111
**Only Arduino/Genuino Mega boards are supported!**
1212

1313
### Installation
1414
This library can be installed through the Arduino IDE library manager like so:
1515
![](installation.gif)
1616

17-
### Note
17+
### Notes
18+
Starting from version 1.3.0 this Servo-Library supports 9 instead of 6 servos! (usable pins are: 2, 3, 5, 6, 7, 8, 44, 45 and 46)
19+
20+
---
21+
1822
Starting from version 1.2.0 this Servo-Library is compatible with all the [original Arduino Servo Library](https://github.com/arduino-libraries/Servo) - commands available. In addition to these "standard"-functions, following commands are added:
1923
* ``` attach(int pin, int min, int max, int defaultPos)``` - Besides the ability to set the servo pin and the upper and lower pulse width limit, the starting pulse width of the servo can be set with the defaultPos. This allows the servo to start from a user-defined angle instead of the middle position.
2024
* ```detachAll()``` - This feature allows detaching all servos at once.
@@ -32,4 +36,5 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
3236
### Acknowledgments
3337
* Inspired by - [original Arduino Servo Library](https://github.com/arduino-libraries/Servo)
3438
* Thanks for helping me to improve my library - [per1234](https://github.com/per1234)
39+
* Thanks for helping me to improve my library - [QuadCorei8085](https://github.com/QuadCorei8085)
3540
* Screen-GIF recorded with - [ShareX](https://getsharex.com/)

examples/Servo_Sweep/Servo_Sweep.ino

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Servo Sweep
22
Created by Daniel Duller, 12. January, 2019.
3-
Changed by Daniel Duller, 11. October, 2019.
3+
Changed by Daniel Duller, 16. November, 2019.
44
This example code is in the public domain.
55
*/
66

@@ -12,39 +12,51 @@ Servo myServo3;
1212
Servo myServo4;
1313
Servo myServo5;
1414
Servo myServo6;
15+
Servo myServo7;
16+
Servo myServo8;
17+
Servo myServo9;
1518

1619
unsigned int valueMicros = 0; //variable that contains the microseconds
1720
int valueDegrees = 0; //variable that contains the degrees
1821

1922
void setup() {
20-
myServo1.attach(2); //attaches the servo to pin 2
21-
myServo2.attach(3);
22-
myServo3.attach(7);
23-
myServo4.attach(8);
24-
myServo5.attach(44);
25-
myServo6.attach(45);
23+
myServo1.attach(2); //attaches the servo to pin 2
24+
myServo2.attach(3);
25+
myServo3.attach(5);
26+
myServo4.attach(6);
27+
myServo5.attach(7);
28+
myServo6.attach(8);
29+
myServo7.attach(44);
30+
myServo8.attach(45);
31+
myServo9.attach(46);
2632
}
2733

2834
void loop() {
29-
//option 1 - using microseconds and the writeMicroseconds-function:
30-
for (valueMicros = 500; valueMicros < 2500; valueMicros++){ //goes from 500us to 2500us (0° to 180°)
31-
myServo1.writeMicroseconds(valueMicros); //writes the value of valueMicros to the servo
32-
myServo2.writeMicroseconds(valueMicros);
33-
myServo3.writeMicroseconds(valueMicros);
34-
myServo4.writeMicroseconds(valueMicros);
35-
myServo5.writeMicroseconds(valueMicros);
36-
myServo6.writeMicroseconds(valueMicros);
37-
delay(1);
38-
}
35+
//option 1 - using microseconds and the writeMicroseconds-function:
36+
for (valueMicros = 500; valueMicros < 2500; valueMicros++){ //goes from 500us to 2500us (0° to 180°)
37+
myServo1.writeMicroseconds(valueMicros); //writes the value of valueMicros to the servo
38+
myServo2.writeMicroseconds(valueMicros);
39+
myServo3.writeMicroseconds(valueMicros);
40+
myServo4.writeMicroseconds(valueMicros);
41+
myServo5.writeMicroseconds(valueMicros);
42+
myServo6.writeMicroseconds(valueMicros);
43+
myServo7.writeMicroseconds(valueMicros);
44+
myServo8.writeMicroseconds(valueMicros);
45+
myServo9.writeMicroseconds(valueMicros);
46+
delay(1);
47+
}
3948

40-
//option 2 - using degrees and the write-function:
41-
for (valueDegrees = 180; valueDegrees > 0; valueDegrees--){ //goes from 180° to 0° (2500us to 500us)
42-
myServo1.write(valueDegrees); //writes the value of valueDegrees to the servo
43-
myServo2.write(valueDegrees);
44-
myServo3.write(valueDegrees);
45-
myServo4.write(valueDegrees);
46-
myServo5.write(valueDegrees);
47-
myServo6.write(valueDegrees);
48-
delay(10);
49-
}
49+
//option 2 - using degrees and the write-function:
50+
for (valueDegrees = 180; valueDegrees > 0; valueDegrees--){ //goes from 180° to 0° (2500us to 500us)
51+
myServo1.write(valueDegrees); //writes the value of valueDegrees to the servo
52+
myServo2.write(valueDegrees);
53+
myServo3.write(valueDegrees);
54+
myServo4.write(valueDegrees);
55+
myServo5.write(valueDegrees);
56+
myServo6.write(valueDegrees);
57+
myServo7.write(valueDegrees);
58+
myServo8.write(valueDegrees);
59+
myServo9.write(valueDegrees);
60+
delay(10);
61+
}
5062
}

extras/functions_explained.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
The functions of the library are:
22

3-
**Servo** -- Class for manipulating servo motors connected to Arduino pins. (**max. 6** elements)
3+
**Servo** -- Class for manipulating servo motors connected to Arduino pins. (**max. 9** elements)
44

5-
**attach(pin)** -- Attaches a servo motor to an i/o pin. (only **pin 2, 3, 7, 8, 44,** and **45**)
5+
**attach(pin)** -- Attaches a servo motor to an i/o pin. (only **pin 2, 3, 5, 6, 7, 8, 44, 45** and **46**)
66

77
**attach(pin, min, max)** -- Attaches a servo motor to an i/o pin with a custom lower and upper pulse width limit.
88

library.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=Servo Hardware PWM
2-
version=1.2.1
2+
version=1.3.0
33
author=Daniel Duller <[email protected]>
44
maintainer=Daniel Duller <[email protected]>
5-
sentence=Allows Arduino/Genuino Mega boards to control up to 6 servos with the integrated 16-bit hardware PWM timer/counter.
6-
paragraph=<br />This library uses the 16-bit hardware timer/counter (timer3, timer4 and timer5) to control the servos.<br />Possible output pins are pin 2, 3, 7, 8, 44, and 45.<br />Unlike the original Servo.h library, this library does not use Timer1.<br />The advantage here is that when using the Wire.h library no fluctuations in the pulse width occur.<br />In addition, I / O registers are addressed directly and not via the digitalWrite()-function (as in Servo.h).<br />
5+
sentence=Allows Arduino/Genuino Mega boards to control up to 9 servos with the integrated 16-bit hardware PWM timer/counter.
6+
paragraph=<br />This library uses the 16-bit hardware timer/counter (timer3, timer4 and timer5) to control the servos.<br />Possible output pins are pin 2, 3, 5, 6, 7, 8, 44, 45 and 46.<br />Unlike the original Servo.h library, this library does not use Timer1.<br />The advantage here is that when using the Wire.h library no fluctuations in the pulse width occur.<br />In addition, I / O registers are addressed directly and not via the digitalWrite()-function (as in Servo.h).<br />
77
category=Device Control
88
url=https://github.com/dadul96/Arduino-Servo-Hardware-PWM-Library
99
architectures=avr

0 commit comments

Comments
 (0)