Driving Robotic Dynamixel Servos ( sending and receiving data ) with Ar...



Hardware

1. Arduino Uno
2. IC 74LS241
3. Breadboard
4. Resistor 10K ohm
5. Dynmixel AX-12A


IC 74LS241 Pin out



Schematic diagram


Dynamixel Servo Ax12A Library

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


Arduino Sketch

#include <AX12A.h>

#define DirectionPin (2u)
#define BaudRate  (57600ul) // <--- Servo baud rate Default 1000000
                                                 //  Please change Arduino Serial monitor baud rate to 57600
                 
                                                 // If  your Servo baud rate 1000000
                                                 //  Please change Arduino Serial monitor baud rate to 1000000
                                               
#define ID (1u)

int reg = 0;

void setup()
{
ax12a.begin(BaudRate, DirectionPin, &Serial);
       delay(1000);
       ax12a.move(1,100);
      delay(1000);
}

void loop()
{
reg = ax12a.readPosition(ID);
Serial.println(reg);

delay(1000);
}

//  function AX12A.h
int readTemperature(unsigned char ID);
int readVoltage(unsigned char ID);
int readPosition(unsigned char ID);
int readSpeed(unsigned char ID);
int readLoad(unsigned char ID);

ความคิดเห็น

แสดงความคิดเห็น