-
Notifications
You must be signed in to change notification settings - Fork 0
/
forward_walk.ino
85 lines (72 loc) · 2.37 KB
/
forward_walk.ino
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <Servo.h>
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
int pos1 = 0;
int pos2 = 0;
int pos3 = 0;
void setup()
{
servo1.attach(4);
servo2.attach(7);
servo3.attach(9);
servo4.attach(11);
servo1.write(90);
servo2.write(90);
servo3.write(90);
servo4.write(90);
delay(2000); //Stay in Lock Position for 2 Sec
}
void loop()
{
for(pos1 = 90, pos2 = 90; pos1 > 70, pos2 > 70; pos1--, pos2--) //left leg up
{
servo1.write(pos1);
servo2.write(pos2);
servo3.write(90);
servo4.write(90);
delay(20);
}
for(pos1 = 90, pos2 = 90; pos1 < 100, pos2 < 100; pos1++, pos2++) //move forward
{
servo1.write(70);
servo2.write(70);
servo3.write(pos1);
servo4.write(pos2);
delay(20);
}
for(pos1 = 70, pos2 = 70; pos1 < 90, pos2 < 90; pos1++, pos2++) //left leg down
{
servo1.write(pos1);
servo2.write(pos2);
servo3.write(100);
servo4.write(100);
delay(20);
}
for(pos1 = 90, pos2 = 90; pos1 < 110, pos2 < 110; pos1++, pos2++) //right leg up
{
servo1.write(pos1);
servo2.write(pos2);
servo3.write(100);
servo4.write(100);
delay(20);
}
for(pos1 = 100, pos2 = 100; pos1 > 90, pos2 > 90; pos1--, pos2--) //move forward
{
servo1.write(110);
servo2.write(110);
servo3.write(pos1);
servo4.write(pos2);
delay(20);
}
for(pos1 = 110, pos2 = 110; pos1 > 90, pos2 > 90; pos1--, pos2--) //right leg down
{
servo1.write(pos1);
servo2.write(pos2);
servo3.write(90);
servo4.write(90);
delay(20);
}
delay(100);
}