Skip to content

Commit 82e12a4

Browse files
committed
Updated Servo library to newest version
1 parent e0bb154 commit 82e12a4

File tree

6 files changed

+70
-47
lines changed

6 files changed

+70
-47
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
= Servo Library for Arduino =
2+
3+
This library allows an Arduino board to control RC (hobby) servo motors.
4+
5+
For more information about this library please visit us at
6+
http://www.arduino.cc/en/Reference/Servo
7+
8+
== License ==
9+
10+
Copyright (c) 2013 Arduino LLC. All right reserved.
11+
Copyright (c) 2009 Michael Margolis. All right reserved.
12+
13+
This library is free software; you can redistribute it and/or
14+
modify it under the terms of the GNU Lesser General Public
15+
License as published by the Free Software Foundation; either
16+
version 2.1 of the License, or (at your option) any later version.
17+
18+
This library is distributed in the hope that it will be useful,
19+
but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21+
Lesser General Public License for more details.
22+
23+
You should have received a copy of the GNU Lesser General Public
24+
License along with this library; if not, write to the Free Software
25+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
Controlling a servo position using a potentiometer (variable resistor)
3-
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
1+
/*
2+
Controlling a servo position using a potentiometer (variable resistor)
3+
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
44
55
modified on 8 Nov 2013
66
by Scott Fitzgerald
7-
http://arduino.cc/en/Tutorial/Knob
7+
http://www.arduino.cc/en/Tutorial/Knob
88
*/
99

1010
#include <Servo.h>
@@ -14,16 +14,14 @@ Servo myservo; // create servo object to control a servo
1414
int potpin = 0; // analog pin used to connect the potentiometer
1515
int val; // variable to read the value from the analog pin
1616

17-
void setup()
18-
{
17+
void setup() {
1918
myservo.attach(9); // attaches the servo on pin 9 to the servo object
2019
}
2120

22-
void loop()
23-
{
24-
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
25-
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
26-
myservo.write(val); // sets the servo position according to the scaled value
27-
delay(15); // waits for the servo to get there
28-
}
21+
void loop() {
22+
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
23+
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
24+
myservo.write(val); // sets the servo position according to the scaled value
25+
delay(15); // waits for the servo to get there
26+
}
2927

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
/* Sweep
2-
by BARRAGAN <http://barraganstudio.com>
2+
by BARRAGAN <http://barraganstudio.com>
33
This example code is in the public domain.
44
55
modified 8 Nov 2013
66
by Scott Fitzgerald
7-
http://arduino.cc/en/Tutorial/Sweep
8-
*/
7+
http://www.arduino.cc/en/Tutorial/Sweep
8+
*/
99

10-
#include <Servo.h>
11-
12-
Servo myservo; // create servo object to control a servo
13-
// twelve servo objects can be created on most boards
14-
15-
int pos = 0; // variable to store the servo position
16-
17-
void setup()
18-
{
19-
myservo.attach(9); // attaches the servo on pin 9 to the servo object
20-
}
21-
22-
void loop()
23-
{
24-
for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees
25-
{ // in steps of 1 degree
26-
myservo.write(pos); // tell servo to go to position in variable 'pos'
27-
delay(15); // waits 15ms for the servo to reach the position
28-
}
29-
for(pos = 180; pos>=0; pos-=1) // goes from 180 degrees to 0 degrees
30-
{
31-
myservo.write(pos); // tell servo to go to position in variable 'pos'
32-
delay(15); // waits 15ms for the servo to reach the position
33-
}
34-
}
10+
#include <Servo.h>
11+
12+
Servo myservo; // create servo object to control a servo
13+
// twelve servo objects can be created on most boards
14+
15+
int pos = 0; // variable to store the servo position
16+
17+
void setup() {
18+
myservo.attach(9); // attaches the servo on pin 9 to the servo object
19+
}
20+
21+
void loop() {
22+
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
23+
// in steps of 1 degree
24+
myservo.write(pos); // tell servo to go to position in variable 'pos'
25+
delay(15); // waits 15ms for the servo to reach the position
26+
}
27+
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
28+
myservo.write(pos); // tell servo to go to position in variable 'pos'
29+
delay(15); // waits 15ms for the servo to reach the position
30+
}
31+
}
3532

Firmware/hardware/Balanduino/avr/libraries/Servo/keywords.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Datatypes (KEYWORD1)
77
#######################################
88

9-
Servo KEYWORD1
9+
Servo KEYWORD1 Servo
1010

1111
#######################################
1212
# Methods and Functions (KEYWORD2)
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name=Servo
2-
version=1.0
2+
version=1.1.0
33
author=Michael Margolis, Arduino
44
maintainer=Arduino <[email protected]>
5-
sentence=Controls a lot of Servos.
5+
sentence=Allows Arduino boards to control a variety of servo motors. For all Arduino boards.
66
paragraph=This library can control a great number of servos.<br />It makes careful use of timers: the library can control 12 servos using only 1 timer.<br />On the Arduino Due you can control up to 60 servos.<br />
7-
url=http://arduino.cc/en/Reference/Servo
8-
architectures=avr,sam
7+
category=Device Control
8+
url=http://www.arduino.cc/en/Reference/Servo
9+
architectures=avr,sam,samd

Firmware/hardware/Balanduino/avr/libraries/Servo/src/Servo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@
6363
#include "avr/ServoTimers.h"
6464
#elif defined(ARDUINO_ARCH_SAM)
6565
#include "sam/ServoTimers.h"
66+
#elif defined(ARDUINO_ARCH_SAMD)
67+
#include "samd/ServoTimers.h"
6668
#else
67-
#error "This library only supports boards with an AVR or SAM processor."
69+
#error "This library only supports boards with an AVR, SAM or SAMD processor."
6870
#endif
6971

7072
#define Servo_VERSION 2 // software version of this library

0 commit comments

Comments
 (0)