Go Down

Topic: Help me understand Serial & processing (Read 878 times) previous topic - next topic


I want to wrap my head around this and maybe you can give some insights...

From my arduino, I'm Serial.print(a) where a = (0 - 2000).
So serial send out one byte at a time so 2000 is not possible so it sends out 2 bytes?

What should I be listening to from processing, 2 bytes? And then reconstructing the bytes to a number value?

Or is it easier to read from the arduino as a string? So I need to end my string value with a 'T' (character) so processing would know that's the end of the string?



Nov 27, 2010, 09:27 pm Last Edit: Nov 27, 2010, 09:28 pm by PaulS Reason: 1
In the absence of any qualifiers (the 2nd argument to Serial.print(), the value is converted to a string, and sent one character at a time.

Since the value you want to send is larger than what fits in a byte, you would need to store the value in an int, and then use highByte() and lowByte() to extract the two bytes. Then, you would use Serial.write() to send the two bytes.

If you send strings (the default behavior), you can send them using println(), so that a carriage return/line feed is appended, and have Processing look for that combination as the terminator.

What should I be listening to from processing

Whatever the Arduino is sending.
The art of getting good answers lies in asking good questions.


thanks, I think that answered my questions.

Go Up