File tree 2 files changed +82
-0
lines changed
2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
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 s1,s2,s3,s4; // created on most boards
13
+
14
+
15
+ int pos = 0 ; // variable to store the servo position
16
+ int t=2000 ;
17
+ void setup () {
18
+ s1.attach (6 );// attaches the servo on pin 9 to the servo object
19
+ s1.write (50 );
20
+ s2.attach (5 );
21
+ s2.write (90 );
22
+ s3.attach (9 ); // attaches the servo on pin 9 to the servo object
23
+ s3.write (55 );
24
+ s4.attach (3 );
25
+ s4.write (90 );
26
+ }
27
+
28
+ void loop () {
29
+
30
+ s1.write (30 );
31
+ delay (t);
32
+ s1.write (40 );
33
+ delay (t);
34
+ s3.write (95 );
35
+ delay (t);
36
+ s1.write (50 );
37
+ delay (t);
38
+ s3.write (75 );
39
+ delay (t);
40
+ s4.write (50 );
41
+ delay (t);
42
+ s3.write (55 );
43
+ delay (t);
44
+ s4.write (70 );
45
+ delay (t);
46
+ s2.write (110 );
47
+ delay (t);
48
+ s4.write (90 );
49
+ delay (t);
50
+ s2.write (90 );
51
+
52
+ // for (pos = 0; pos <= 180; pos += 90) { // goes from 0 degrees to 180 degrees
53
+ // // in steps of 1 degree
54
+ // myservo.write(pos); // tell servo to go to position in variable 'pos'
55
+ // delay(100); // waits 15ms for the servo to reach the position
56
+ // }
57
+ // for (pos = 180; pos >= 0; pos -= 90) { // goes from 180 degrees to 0 degrees
58
+ // myservo.write(pos); // tell servo to go to position in variable 'pos'
59
+ // delay(); // waits 15ms for the servo to reach the position
60
+ // }
61
+ }
62
+
Original file line number Diff line number Diff line change
1
+ #include < Servo.h>
2
+ Servo s1, s2, s3, s4;
3
+
4
+ void setup ()
5
+ {s1.attach (6 );// attaches the servo on pin 9 to the servo object
6
+ s1.write (90 );
7
+ s2.attach (5 );
8
+ s2.write (90 );
9
+ s3.attach (9 ); // attaches the servo on pin 9 to the servo object
10
+ s3.write (90 );
11
+ s4.attach (3 );
12
+ s4.write (90 );
13
+
14
+ }
15
+ void loop ()
16
+ {
17
+ s1.write (30 );
18
+ s2.write (40 );
19
+ }
20
+
You can’t perform that action at this time.
0 commit comments