Arduino controls Dynamixel AX-12A's robotic arm each joint turns 45 degrees

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.