Skip to content

Commit cdec83c

Browse files
author
Federico Fissore
committed
Run new astyle formatter against all the examples
1 parent 028be17 commit cdec83c

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

examples/Knob/Knob.ino

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
// Controlling a servo position using a potentiometer (variable resistor)
2-
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
1+
// Controlling a servo position using a potentiometer (variable resistor)
2+
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>
3+
4+
#include <Servo.h>
5+
6+
Servo myservo; // create servo object to control a servo
37

4-
#include <Servo.h>
5-
6-
Servo myservo; // create servo object to control a servo
7-
88
int potpin = 0; // analog pin used to connect the potentiometer
9-
int val; // variable to read the value from the analog pin
10-
11-
void setup()
12-
{
13-
myservo.attach(9); // attaches the servo on pin 9 to the servo object
14-
}
15-
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-
}
9+
int val; // variable to read the value from the analog pin
10+
11+
void setup()
12+
{
13+
myservo.attach(9); // attaches the servo on pin 9 to the servo object
14+
}
15+
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+
}

examples/Sweep/Sweep.ino

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
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

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