Hey, I'm making a 2 DOF arm, and am having some trouble getting precise angle calculations out of my arduino. Is there something I can do to make them more accurate? I'm new to arduino so I recognize my programming skills aren't that great, so I may be doing something quite obvious wrong.
float c = sqrt(sq(x) + sq(y)); //pythagorean theorem to find imaginary line c
float middleRad = acos((sq(c)-sq(a)-sq(b))/((-2)*a*b)); //law of cosines, returns angle of middle servo in radians
//law of cosines for base angle
float baseRad = acos((sq(b)-sq(a)-sq(c))/((-2)*a*c)) + atan(y/x);
//converting Radians to Degrees:
float baseDeg = baseRad*(180/PI);
float middleDeg = middleRad*(180/PI);
probably should have explained more. I'm converting to degrees so that the angles are now in the range of 0-180 for the servos to read. is there a better way to have the servos write to the angles?