私の任務は、2 つのループの直径が少なくとも 1 フィートである「8 の字」で Shield-Bot を継続的に実行させるソフトウェアを設計および実装することです。
私は次のコードをまとめました。これにより、最初は 8 の字が正しく作成されますが、その後、回転するたびにゆっくりと形が失われます。私は同じように各回転が必要です。
#include <Servo.h>
//declare servo motor variables
Servo leftServo;
Servo rightServo;
void loop() {
//assign i/o pins to servo
leftServo.attach(13);
rightServo.attach(12);
//Declare values for the first circle
int leftFirtCirlceSpeed=1548;
int rightFirstCircleSpeed=1300;
//send pulse to each servo motor. Servo circles
leftServo.writeMicroseconds(leftFirtCirlceSpeed);
rightServo.writeMicroseconds(rightFirstCircleSpeed);
delay(13000);
//declare left/right servo int and assign these variables the pulse width so that the servo stops
//int leftStop = 1500;
//int rightStop = 1500;
//send pulse to each servo motor. Servo stops
//leftServo.writeMicroseconds(leftStop);
//rightServo.writeMicroseconds(rightStop);
//delay(100);
//declare left/right servo int and assign these variables the pulse width so that the servo goes straight
int leftStraight = 1700;
int rightStraight = 1300;
//send pulse to each servo motor. Servo goes straight
leftServo.writeMicroseconds(leftStraight);
rightServo.writeMicroseconds(rightStraight);
delay(2000);
//Declare values for the second circle
int leftSecondCircleSpeed = 1700;
int rightSecondCircleSpeed = 1458;
//send pulse to each servo motor. Servo circles
leftServo.writeMicroseconds(leftSecondCircleSpeed);
rightServo.writeMicroseconds(rightSecondCircleSpeed);
delay(9000);
//leftServo.writeMicroseconds(leftStop);
//rightServo.writeMicroseconds(rightStop);
//delay(100);
//send pulse to each servo motor. Servo goes straight
leftServo.writeMicroseconds(leftStraight);
rightServo.writeMicroseconds(rightStraight);
delay(2000);
}