目標座標へ2つのサーボを動かし、元の座標地までもどして、また目標座標へサーボを動かしてを繰り返すプログラムを作りたいのですが目標座標へ動いて止まってしまいます。どのように改善したら良いでしょうか?回答お願いします。
#include<stdio.h>
#include<math.h>
#include<Servo.h>
Servo servo1,servo2;
double a,b,c,x,y,pos1,pos2,pos3,pos4,pos5,A,B,C,D,radian1,radian2;
void setup(){
servo1.attach(9);
servo2.attach(7);
y=5;
b=5;
c=5;
a=sqrt(xx+yy);
pos1=((bb+cc-aa)/(2bc));
radian1=acos(pos1);
A=radian1180/M_PI;//M_PI(円周率)
B=180-A;//二個目のモーターの角度
pos2=(y/x);
pos5=((bb+aa-cc)/(2ba));
D=acos(pos5);
radian2=atan(pos2);
C=radian2180/M_PI-D;//一つ目のモーターの角度
}
void loop(){
for ( x = 0; x < 5; x += 1 ) {
servo1.write(C);
delay(1000);
servo2.write(B);
delay(1000);
}
for ( x = 5; x > 0; x -= 1 ) {
servo1.write(C);
delay(1000);
servo2.write(B);
delay(1000);
}
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。