1. Turn 45 per joint, reciprocating cycle
#include <ax12.h>void setup () {setposition (1,511);//set the position of servo # 1 to ' 511 ' setposition (2,5 11); SetPosition (3,511); SetPosition (4,511); SetPosition (5,400); Delay (//wait), Servo to Move}void Loop () {//increment from 511 to 664 for (int i=511;i<664;i++) {//set the position of servo #1 to the current value of ' I ' setposition (2,i); SetPosition (3,i); SetPosition (4,i); SetPosition (5,i-111); Delay (664);//wait for Servo to move} delay (//wait); To 511 for (int. i=664;i>511;i--) {//set The position of servo #1 to the current value of ' I ' SetPosition (2,i); SetPosition (3,i); SetPosition (4,i); SetPosition (5,i-111); Delay (//wait for servo to move} delay (1000);//Wait for servo to move}
2. Turn it once and return to the position
#include <ax12.h> void Setup () { setposition (1,511); SetPosition (2,511); SetPosition (3,511); SetPosition (4,511); SetPosition (5,400); Delay (100);} void Loop () { //increment from 0 to 1023 for (int i=511;i<664;i++) { setposition (2,i); SetPosition (3,i); SetPosition (4,i); SetPosition (5,i-111); Delay (ten); } Delay (+); for (int i=664;i>511;i--) { setposition (2,i); SetPosition (3,i); SetPosition (4,i); SetPosition (5,i-111); Delay (ten); } Delay (+); }
Summarize:
At first do not know how to jump out of the loop (), can only use this method, do not know if there is no statement can jump directly.
Arduino controls Dynamixel AX-12A's robotic arm each joint turns 45 degrees