Ok so a quick search found nothing... How can i send an integer via serial?
Serial.print(yourInteger);
will send it but you must mean something different.
I meant as an integer. >_< The datatype, 4 bytes. Like how you can specify, BYTE, etc. How can i send it as an integer? AKA int
You would need to split the integer into 2 shorts. Then split each short into 2 bytes. Then, send each of the bytes, in the correct order.
Of course, they need to be re-combined the same way, by the receiver.
There's another thread in this forum discussing how to send a short. Just extend the concept to splitting the int into 2 shorts.
You would need to split the integer into 2 shorts. Then split each short into 2 bytes. Then, send each of the bytes, in the correct order.
Of course, they need to be re-combined the same way, by the receiver.
There's another thread in this forum discussing how to send a short. Just extend the concept to splitting the int into 2 shorts.
whoah, i thought an int WAS 2 bytes long!
For the Arduino, an int is two bytes.
depending on the capabilities of the recieving end, it might be easyer to use itoa() to turn the int into a string and send it as ASCII, and then convert it back to an int in the recieving program (if possible).