Hi, thanks for the quick reply!
PaulS:
VB (this code basically sends a string of several bytes, which are stored in a,b,c,...) :
Why are you concatenating stuff like that? Use an array, like a normal person.
That's exactly what I am planning to do as stated in my first post. You asked me for the code with string-transmission and that's why I posted it...
PaulS:
if (Serial.available())
{
Serial.flush();
Do you have a clue what flush() does? If so, please tell us why, in great detail, you are calling that function here. If not, please tell us why, in great detail, you are calling that function here.
Ok, you're right, doesn't make much sense here. Sorry. Waits for the outgoing serial data to complete. Which I don't have here...
PaulS:
while(i<9)
{
buffer[i] = serial.read();
i++;
}
Serial.flush();
If there is at least one byte to read, read all 9 of them. Does that make sense to you? It doesn't to me.
You have some dumb idea that serial data transmission is guaranteed. It is not. Get over it.
> Is it also possible to send an array like this?
No. data(9) is NOT an array.
Yes, doesn't make much sense, I need all 9 byte to be sent so that I can read them...
And yes, I know this isn't guaranteed....
And yep, I meant data[] with an array size of 9. Sorry, I was in a bit of hurry, wenn I wrote the answer... So is it possible to send it like this
SerialPort1.Write(data[]))
PaulS:
Is this possible?
Yes, but that will NOT read 9 bytes.
Why not? Ok, I forgot i++, but otherwise would it do so? And if not, why not. How do I manage to read those 9 bytes?
PaulS:
To send sensor and encoder data back to the computer.
You seem to be confusing the meaning of to and from. If you want to send sensor and encoder data FROM the Arduino, then the Arduino wouldn't be reading anything from the serial port. It would be writing TO the serial port.
Why are you sending an array TO the Arduino?
Sorry, you are right, later on I need both directions. Right now I am concentrating on the part from PC to arduino and somehow I thought you would ask why I also needed the other direction (which I even didn't mention in my first post
). My mistake...
From the PC to the arduino it is to control several servos and motor controllers...
Sorry again!