I am a newbie in Arduino and serial communication. I am working on a project that use Arduino to send data bits to an actuator using RS232 communication protocol. In order to control the actuator, an instruction consists of 6 bytes must be sent with 9600 baud, no hand shaking, 8N1 format.
Here are the instructions: Byte 1 - Device, Byte 2 - Command, Byte 3 - Data(LSB), Byte 4 - Data, Byte 5 - Data, Byte 6 - Data(MSB)
For example to send 1, 20, 1, 1, 0, 0 (Move the actuator to absolute position of 257 microsteps)
This is my draft code. How can I send start and stop bit? I am confused on sending start and stop bit. The Serial.write() is sending binary data as a byte. Does it mean that I write Serial.write(20), the compiler will send the data in 00010100 binary format? I am quite frustrated with serial communication.
Serial.write
is working on a level of bytes and byte arrays, not bits. You don't need to implement the lower level stuff when using it. Anyway, looks like a major misunderstanding of things. – Eugene Sh. Mar 23 '17 at 18:42