Skip to content

Commit 1892447

Browse files
Fix issue 196, for Servo library
1 parent 8345e6f commit 1892447

File tree

7 files changed

+92
-29
lines changed

7 files changed

+92
-29
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Controlling a servo position using a potentiometer (variable resistor)
3+
by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
4+
5+
modified on 8 Nov 2013
6+
by Scott Fitzgerald
7+
http://www.arduino.cc/en/Tutorial/Knob
8+
*/
9+
10+
#include <Servo.h>
11+
12+
Servo myservo; // create servo object to control a servo
13+
14+
int potpin = 0; // analog pin used to connect the potentiometer
15+
int val; // variable to read the value from the analog pin
16+
17+
void setup() {
18+
myservo.attach(9); // attaches the servo on pin 9 to the servo object
19+
}
20+
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+
}
27+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* Sweep
2+
by BARRAGAN <http://barraganstudio.com>
3+
This example code is in the public domain.
4+
5+
modified 8 Nov 2013
6+
by Scott Fitzgerald
7+
http://www.arduino.cc/en/Tutorial/Sweep
8+
*/
9+
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+
}
32+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#######################################
2+
# Syntax Coloring Map Servo
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
Servo KEYWORD1 Servo
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
attach KEYWORD2
15+
detach KEYWORD2
16+
write KEYWORD2
17+
read KEYWORD2
18+
attached KEYWORD2
19+
writeMicroseconds KEYWORD2
20+
readMicroseconds KEYWORD2
21+
22+
#######################################
23+
# Constants (LITERAL1)
24+
#######################################
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Servo(STM32F1)
2+
version=1.1.2
3+
author=Unknown (possibly LeafLabs)
4+
maintainer=Roger Clark ([email protected])
5+
sentence=Allows STM32 boards to control a variety of servo motors.
6+
paragraph=
7+
category=Device Control
8+
url=http://www.arduino.cc/en/Reference/Servo
9+
architectures=STM32F1

STM32F1/libraries/Servo/rules.mk

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)