Using Dynamixel AX-12A Servo with Arduino






Wiring Diagram


AX-12A  pin1: GND  --->  DC -12V
AX-12A  pin2: VDD  --->   DC +12V
AX-12A pin3: DATA --->  Tx pin of Arduino

*** Connect  the two grounds together ***

Ax-12A Library
https://github.com/ThingType/AX-12A-servo-library


Arduino Sketch

*
 * Example showing how to use endless mode (wheel mode) on AX-12A
 * Be sure you removed all mechanical assemblies (hinges) before using this code !
 */

#include <AX12A.h>

#define DirectionPin (10u)
#define BaudRate  (1000000ul)
#define ID (1u)

void setup()
{
ax12a.begin(BaudRate, DirectionPin, &Serial);
ax12a.setEndless(ID, ON);

}

void loop()
{
    ax12a.ledStatus(ID, ON);
    ax12a.turn(ID, LEFT, 100);
    delay(5000);
 
    ax12a.ledStatus(ID, OFF);
    ax12a.turn(ID, RIGHT, 500);
    delay(5000);
}

ความคิดเห็น