Skip to content

Commit caaf806

Browse files
author
Federico Fissore
committed
Examples: mass code format. See example_formatter.conf
1 parent a6467fb commit caaf806

File tree

2 files changed

+34
-39
lines changed

2 files changed

+34
-39
lines changed

examples/Knob/Knob.ino

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

examples/Sweep/Sweep.ino

Lines changed: 24 additions & 27 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
77
http://www.arduino.cc/en/Tutorial/Sweep
8-
*/
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

0 commit comments

Comments
 (0)