So currently, I am having problem just basically printing angle outputs in the serial monitor. From my understanding, Arduino Uno only has one serial port which gets occupied by the dynamixel shield to communicate with the motor, hence it is not able to print anything on the serial monitor. So I thought CP2102 could help out with that but I am having no luck trying to figure it out. If my understanding is incorrect, please correct me.
Below is my code:
#include <DynamixelShield.h>
#include <SoftwareSerial.h>
// DYNAMIXELShield UART RX/TX
SoftwareSerial soft_serial(7, 8);
// Create CP_SERIAL on a different set of pins (e.g., 10 and 11)
SoftwareSerial CP_SERIAL(10, 11);
const uint8_t DXL_ID = 1;
const float DXL_PROTOCOL_VERSION = 2.0;
DynamixelShield dxl;
using namespace ControlTableItem;
void setup() {
// Use the software serial port for the Dynamixel Shield
soft_serial.begin(115200);
dxl.begin(57600);
dxl.setPortProtocolVersion(DXL_PROTOCOL_VERSION);
dxl.ping(DXL_ID);
// Start the CP_SERIAL port on its own pins
CP_SERIAL.begin(9600);
dxl.torqueOff(DXL_ID);
dxl.setOperatingMode(DXL_ID, OP_POSITION);
dxl.torqueOn(DXL_ID);
}
void loop() {
dxl.setGoalPosition(DXL_ID, 512);
delay(1000);
CP_SERIAL.print("Present Position(raw) : ");
CP_SERIAL.println(dxl.getPresentPosition(DXL_ID));
delay(1000);
dxl.setGoalPosition(DXL_ID, 5.7, UNIT_DEGREE);
delay(1000);
CP_SERIAL.print("Present Position(degree) : ");
CP_SERIAL.println(dxl.getPresentPosition(DXL_ID, UNIT_DEGREE));
delay(1000);
CP_SERIAL.println(“Hello SIr”);
}
This is the modified version of the position mode basic code.
Please help me out on this… I just wanna see the output!