Skip to content

Commit b7ef849

Browse files
committed
Merge remote-tracking branch 'arduino/master' into ide-1.5.x
Conflicts: libraries/Ethernet/examples/XivelyClient/XivelyClient.ino libraries/Ethernet/examples/XivelyClientString/XivelyClientString.ino libraries/GSM/examples/GSMXivelyClient/GSMXivelyClient.ino libraries/GSM/examples/GSMXivelyClientString/GSMXivelyClientString.ino libraries/Servo/examples/Knob/Knob.ino libraries/Servo/examples/Sweep/Sweep.ino libraries/WiFi/examples/WiFiXivelyClient/WiFiXivelyClient.ino libraries/WiFi/examples/WiFiXivelyClientString/WiFiXivelyClientString.ino
2 parents cdec83c + bec6bcf commit b7ef849

File tree

2 files changed

+48
-37
lines changed

2 files changed

+48
-37
lines changed

examples/Knob/Knob.ino

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
// Controlling a servo position using a potentiometer (variable resistor)
2-
// 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>
4+
5+
modified on 8 Nov 2013
6+
by Scott Fitzgerald
7+
http://arduino.cc/en/Tutorial/Knob
8+
*/
39

410
#include <Servo.h>
511

@@ -13,10 +19,11 @@ void setup()
1319
myservo.attach(9); // attaches the servo on pin 9 to the servo object
1420
}
1521

16-
void loop()
17-
{
18-
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
19-
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
20-
myservo.write(val); // sets the servo position according to the scaled value
21-
delay(15); // waits for the servo to get there
22-
}
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+
}
29+

examples/Sweep/Sweep.ino

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

6-
#include <Servo.h>
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+
}
735

8-
Servo myservo; // create servo object to control a servo
9-
// a maximum of eight servo objects can be created
10-
11-
int pos = 0; // variable to store the servo position
12-
13-
void setup()
14-
{
15-
myservo.attach(9); // attaches the servo on pin 9 to the servo object
16-
}
17-
18-
19-
void loop()
20-
{
21-
for (pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
22-
{ // in steps of 1 degree
23-
myservo.write(pos); // tell servo to go to position in variable 'pos'
24-
delay(15); // waits 15ms for the servo to reach the position
25-
}
26-
for (pos = 180; pos >= 1; pos -= 1) // goes from 180 degrees to 0 degrees
27-
{
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-
}

0 commit comments

Comments
 (0)