My assignment is to design and implement software to cause your Shield-Bot to run continuously in a “figure 8” where the two loops are at least 1 foot in diameter.
I have put the following code together, which makes a figure 8 correctly the first time, but then after each rotation around it slowly loses form. I need each rotation the same way.
#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);
}