forked from VAR-solutions/Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkittybot.ino
More file actions
62 lines (53 loc) · 1.41 KB
/
kittybot.ino
File metadata and controls
62 lines (53 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo s1,s2,s3,s4; // created on most boards
int pos = 0; // variable to store the servo position
int t=2000;
void setup() {
s1.attach(6);// attaches the servo on pin 9 to the servo object
s1.write(50);
s2.attach(5);
s2.write(90);
s3.attach(9); // attaches the servo on pin 9 to the servo object
s3.write(55);
s4.attach(3);
s4.write(90);
}
void loop() {
s1.write(30);
delay(t);
s1.write(40);
delay(t);
s3.write(95);
delay(t);
s1.write(50);
delay(t);
s3.write(75);
delay(t);
s4.write(50);
delay(t);
s3.write(55);
delay(t);
s4.write(70);
delay(t);
s2.write(110);
delay(t);
s4.write(90);
delay(t);
s2.write(90);
//for (pos = 0; pos <= 180; pos += 90) { // goes from 0 degrees to 180 degrees
// // in steps of 1 degree
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// delay(100); // waits 15ms for the servo to reach the position
// }
// for (pos = 180; pos >= 0; pos -= 90) { // goes from 180 degrees to 0 degrees
// myservo.write(pos); // tell servo to go to position in variable 'pos'
// delay(); // waits 15ms for the servo to reach the position
// }
}