I'm working on a robotic dog project and the servo TFR goes to the angle 93 despite no angle ever being written to the TFR servo. In addition the TWBRR servo would go to the same position as the TWFR servo despite no write command to the TWBRR servo (That's why it's commented out). Any Ideas?
#include <Servo.h>
float x;
float anga;
float angarad;
float angb;
float angbrad;
float angl;
Servo TFL;
Servo BFL;
Servo TWFL;
Servo TFR;
Servo BFR;
Servo TWFR;
Servo TBL;
Servo BBL;
Servo TWBL;
Servo TBR;
Servo BBR;
Servo TWBRR;
void setup() {
// put your setup code here, to run once:
TFL.attach(48);
BFL.attach(46);
TWFL.attach(51);
TFR.attach(50);
BFR.attach(52);
TWFR.attach(53);
TBL.attach(44);
BBL.attach(47);
TWBL.attach(49);
TBR.attach(43);
BBR.attach(42);
//TWBRR.attach(45);
Serial.begin(9600);
Serial.println("Begin");
//TFR.write(15);
BFR.write(90);
TWFR.write(95);
x = 150;
delay(1000);
}
void loop() {
delay(100);
angarad = acos(x/180);
anga = ((angarad * 180) / 3.14159);
angbrad = 90 - acos(x/194);
angb = ((angbrad * 180) / 3.14159);
//BFR rotates CCW with increasing values.
//TFR rotates CCW with increasing values.
BFR.write(90-anga);
angl = TFR.read();
Serial.println(angl);
delay(100);
}