I need to send an integer, say between 0-10000, to Arduino using serial communication. What is the best way to do this?
I can think of breaking the number into an array of characters (for example: 500 as "5", "0", "0") and send them as a stream of bytes (yes, this is ugly). Then rebuild on the other end. (anything is sent in serial as a stream of bytes, right?)
Isn't there a better way? One way or another, it should be able to assign a value to a variable of type int .
(really, you need to know the same thing about strings, if possible)
source share