
180 Make: Robotic Arms
alphaOne = acos(d/c);
alphaTwo = acos((linkTwo*linkTwo + c*c -
linkThree*linkThree)/(2*linkTwo*c));
if(z > linkOne){
alphaFinal = (alphaOne+alphaTwo)*(180/PI);
}
else if(z < linkOne){
alphaFinal = (alphaOne-alphaTwo)*(180/PI);
}
servoOne.write(theta);
servoTwo.write(alphaFinal);
servoThree.write(180-alphaFinal);
servoFour.write(beta);
Serial.print("Theta: ");
Serial.print(theta);
Serial.print(" Alpha: ");
Serial.print(alphaFinal);
Serial.print(" Beta: ");
Serial.println(beta);
delay(3000);
}
}
The first portion of our code, all the way through our void setup, is exactly the
same as before. The biggest changes we have ...