I am using a ak70 motor which I can control (servo) using the CAN protocol easily. However, I cannot even make basic communications between the arduino MEGA and the motor using serial communication, via UART. The following code is what I am using:
#include <SoftwareSerial.h>
SoftwareSerial motorSerial(10, 11); // RX, TX
byte rotate90deg = {
0xAA, 0x05, 0x4A, 0x05, 0x5D, 0x4A, 0x80, 0x84, 0x93, 0xBB
};
unsigned long lastSend = 0;
void setup() {
Serial.begin(115200);
motorSerial.begin(115200);
Serial.println(“Sending new protocol GET_VALUES every 2s…”);
}
void loop() {
if (millis() - lastSend > 2000) {
motorSerial.write(rotate90deg, sizeof(rotate90deg));
Serial.println(“Sent”);
lastSend = millis();
}
while (motorSerial.available()) {
byte b = motorSerial.read();
Serial.print(b, HEX);
Serial.print(" ");
}
}
Can anyone please help me with this?
Thanks