-
Notifications
You must be signed in to change notification settings - Fork 0
/
chaotic_fast.ino
92 lines (67 loc) · 1.58 KB
/
chaotic_fast.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
86
87
88
89
90
91
92
#include <Servo.h>
Servo servoA;
Servo servoB;
Servo servoC;
int ledTemoin = 8;
float angleA = 40;
float angleB = 40;
float angleC = 40;
float speedA = 0.06; // deg per millisecond
float speedB = 0.14;
float speedC = 0.22;
/*float speedA = 0.007*3;
float speedB = 0.011*3;
float speedC = 0.018*3;*/
bool AGoUp = true;
bool BGoUp = true;
bool CGoUp = true;
void setup() {
// put your setup code here, to run once:
pinMode(ledTemoin, OUTPUT); // led temoin
digitalWrite(ledTemoin,HIGH);
servoA.attach(9); //servo A
servoB.attach(11); //servo B
servoC.attach(10); //servo C
delay(500);
servoA.writeMicroseconds((-2160+1260)*float(45)/90 + 2160);
servoB.writeMicroseconds((-1975+1130)*float(45)/90 + 1975);
servoC.writeMicroseconds((-1955+1130)*float(45)/90 + 1955);
delay(300);
}
void loop() {
digitalWrite(ledTemoin , millis() / 500 % 2 ); // blink led
servoA.writeMicroseconds((-2160+1260)*float(angleA)/90 + 2160);
servoB.writeMicroseconds((-1975+1130)*float(angleB)/90 + 1975);
servoC.writeMicroseconds((-1955+1130)*float(angleC)/90 + 1955);
if(angleA >= 90){
AGoUp = false;
}if(angleA <= 40){
AGoUp = true;
}
if(angleB >= 90){
BGoUp = false;
}if(angleB <= 40){
BGoUp = true;
}
if(angleC >= 90){
CGoUp = false;
}if(angleC <= 40){
CGoUp = true;
}
if(AGoUp == true){
angleA += speedA;
}else{
angleA -= speedA;
}
if(BGoUp == true){
angleB += speedB;
}else{
angleB -= speedB;
}
if(CGoUp == true){
angleC += speedC;
}else{
angleC -= speedC;
}
delay(1);
}