Hi Programmers,
I am trying to read data from Futaba servo motor to check a current position.
Some Futaba servo provides TTL communication for control servo motor and read data of current status, position, speed, Id, etc..
I am using Arduino UNO and a serial interface board that I made it using 74HC125. And I am using SoftwareSerial library.
You can see the attached my whole code.
It is working to communicate between my mac and servo motor, sending command to control servo motor and reading a status data from servo.
below code is part of read and display on the serial monitor, it is working.
Serial.print(ServoSerial.read(),HEX);
Serial.print(",");
you can see the attached image "Success to read data"
But I have a problem to read data and save it into variable. When I saved data into variable, it seems there are wrong data.
data = (ServoSerial.read(),HEX);
Serial.print(data*); *
Serial.print(","); [/b]
you can see the attached image "Fail to read #1"
And I tried a different way to read using 'string'
char received = (char)(ServoSerial.read(),HEX); //add
inData += received; //add
inData += ",";
Serial.print(inData); //add
you can see the attached image "Fail to read #2"
I wonder what is difference between using Serial.print with serial monitor and saving data into variable or string.
Please advise or comments for me.
Thank you.
FutabaServoReadTest.ino (2.97 KB)