how to use the UART ?

MY system is windows, and my board is arduino mega. i want to use the uart3(TX3,RX3) to communicate with another component.

my code is:

int buf[]={FF FF 00 07 03 1E 00 02 00 02 D3}; void setup(){

Serial3.begin(500000);

} void loop() { Serial3.write(buf,11); }

but its said"27: error: exponent has no digits".

What can i do? I am a beginner, and I need the help of yours. Thanks! :'(

The baud rate that you can set, using Serial.begin() is not some random value. 500000 is not a valid choice.

int buf[]={FF FF 00 07 03 1E 00 02 00 02 D3};

You need commas between these numbers. Also prefix each with “0x” to indicate hexadecimal notation.

Since the values are bytes and Serial.write expects bytes you’d better make it “byte buf”.

thank you. I correct it, there is no error now, but the servo motor still can't work, why??

(the baud ratio of the servo motor is 500k default .)

How can It communicates with the motor using UART ?

THANK you very much!

the baud ratio of the servo motor is 500k default

Can you provide us with a link to the servo’s datasheet?
Standard R/C servos don’t use serial communications.
Lefty

There isn't online datasheet of the servo motor. (There is a controller in it, so it can communicate with the UART of Arduino Mega.)

Now it can transmit data to the motor at the baud ratio of 500k.

But there is still a question: How can I see the data the motor received?? the Serial Monitor? there isn't any thing display on it, and it doesn't have the baud ratio of 500k.

What can I do? Thank you!

so use a bitrate supported by serial monitor while testing

Do you have a data sheet for the servo - online or not? If not, how do you know what commands to send to it to make it do anything?

Is there a data sheet, model number, manufacturer name, or anything you can tell us about the servo controller?

The speed that the controller communicates with the servo is completely independent of the speed that the controller communicates with the Arduino.

Serial3.begin(500000);

Sounds like you are confusing baud rate with frequency.

Try 2400 baud (for 500kHz).

how do you know what commands to send to it to make it do anything?

... That is a really good point.

I have the datasheet. The motor is SR518, which compatible with the Dynamixal servo.

"The speed that the controller communicates with the servo is completely independent of the speed that the controller communicates with the Arduino. " ?
The default baud ratio of the servo is 500k bps, and I can send data only when I set the baud ratio 500k. ( Serial.begin(500000) ).

How can I see the data the controller(Arduino Mega) received ? :’(

Thank you!

How can I see the data the controller(Arduino Mega) received

If it's a Mega, you've got three other serial ports.

How can I see the data the controller(Arduino Mega) received ? :'( :'( :'(

How is the controller receiving data? Tell us that, and we'll tell you how you can see what that data is.

The controller is the Arduino Mega Board.

A baud rate is not equal to the bit rate.

http://www.pccompci.com/Baud_Rate.html

And I strongly suggest that the 500k bps is not your baud rate.