-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath_trigo.ino
50 lines (34 loc) · 1.02 KB
/
math_trigo.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
void math_trigo() {
int pos=0;
int a =120;
int b =140;
int c =100;
float Atheta,Btheta,Ctheta,z,D;
float NewA, Acalk,Bcalk,Ccalk,All_angles;
Acalk = (pow(b, 2) + pow(c, 2) - pow(a, 2)) / (float(b * c)*2);
Bcalk= (pow(a, 2) + pow(c, 2) - pow(b, 2)) / (float(a * c)*2);
Ccalk = (pow(a, 2) + pow(b, 2) - pow(c, 2)) / (float(a * b)*2);
Atheta = acos(Acalk)*180/PI;
Btheta = acos(Bcalk)*180/PI;
Ctheta = acos(Ccalk)*180/PI;
All_angles = (Atheta+Btheta+Ctheta);
Serial.println(Atheta);
delay(1000);
Serial.println(Btheta);
delay(1000);
Serial.println(Ctheta);
//delay(1000);
servo1.write(Atheta); //servo 1,2,3 for front Right left
servo2.write(Btheta);
//servo3.write(110);
//servo4.write(pos);
//servo5.write(pos);
//servo6.write(pos);
//servo7.write(pos);
//servo8.write(pos);
//servo9.write(pos);
//servo10.write(pos);
//servo11.write(pos);
//servo12.write(pos);
//D = 90 - ((Ctheta * 180) / PI);
}